mirror of
https://github.com/abdelkader/vCardEditor
synced 2025-12-12 08:27:19 +07:00
Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba9d26f981 | ||
|
|
abbb03dddf | ||
|
|
a989351889 | ||
|
|
22f7f88018 | ||
|
|
85bb588f42 | ||
|
|
1bf467f81f | ||
|
|
7e8c43e011 | ||
|
|
7d09a9ee3e | ||
|
|
77c1e45bfd | ||
|
|
1f234c61e9 | ||
|
|
927d36a9a0 | ||
|
|
653f21b9cc | ||
|
|
f509d5da84 | ||
|
|
9012d355d3 | ||
|
|
88efefef5e | ||
|
|
c244f09b92 | ||
|
|
1df41c4714 | ||
|
|
634f82b3bb | ||
|
|
016c23d4fc | ||
|
|
e3171db86d | ||
|
|
2bf9cd6064 | ||
|
|
81a63e8281 | ||
|
|
8cda766954 | ||
|
|
194ee7e56c | ||
|
|
a0a6c4900c | ||
|
|
449c22f576 | ||
|
|
0020c3e6c8 | ||
|
|
397279be43 | ||
|
|
d6f5e2f316 | ||
|
|
5a87bc104f |
@@ -24,12 +24,16 @@ The software is still in **early stage**.
|
||||
- 📖 [MVP pattern from this example](https://github.com/lennykean/NoteCards)
|
||||
- 🧰 [SortableBindingList](http://timvw.be/2008/08/02/presenting-the-sortablebindinglistt-take-two/)
|
||||
- 🧰 [Custom TabControl](https://github.com/r-aghaei/TabControlWithCloseButtonAndAddButton)
|
||||
- 🧰 [QRCoder](https://github.com/codebude/QRCoder)
|
||||
|
||||
## 📑 Release notes
|
||||
Check release text file for history.
|
||||
|
||||
## 👷 Contributing
|
||||
|
||||
## 👷 Contributing and help
|
||||
Contributions are always welcome! Check ths projet or ths issue page for ideas.
|
||||
- 📝 [**Report a bug**](https://github.com/abdelkader/vCardEditor/issues)
|
||||
- 🙋♀️ [**Request a feature**](https://github.com/abdelkader/vCardEditor/discussions)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
446
properties.md
Normal file
446
properties.md
Normal file
@@ -0,0 +1,446 @@
|
||||
Some properties are not supported by the library **Tought.vCards**.
|
||||
AGENT, ANNIVERSARY, CALADRURI, CALURI, CLIENTPIDMAP, FBURL, GENDER, KIND, LANG, LOGO, MEMBER, PROFILE, RELATED, SORT-STRING, SOUND.
|
||||
|
||||
<h3>Already implemented ✅ in version 5.0 </h3>
|
||||
<table>
|
||||
<tr>
|
||||
<td rowspan="2"><b>Name</b></td>
|
||||
<td colspan="3"><b>Property presence</b></td>
|
||||
<td rowspan="2"><b>Description</b></td>
|
||||
<td rowspan="2"><b>Example</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>v. 2.1</b></td>
|
||||
<td><b>v. 3.0</b></td>
|
||||
<td><b>v. 4.0</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ADR</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>A structured representation of the physical delivery address for the vCard object.</td>
|
||||
<td>ADR;TYPE=home:;;123 Main St.;Springfield;IL;12345;USA</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>BEGIN</td>
|
||||
<td>Required</td>
|
||||
<td>Required</td>
|
||||
<td>Required</td>
|
||||
<td>All vCards must start with this property.</td>
|
||||
<td>BEGIN:VCARD</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>EMAIL</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>The address for electronic mail communication with the vCard object.</td>
|
||||
<td>EMAIL:johndoe@hotmail.com</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>END</td>
|
||||
<td>Required</td>
|
||||
<td>Required</td>
|
||||
<td>Required</td>
|
||||
<td>All vCards must end with this property.</td>
|
||||
<td>END:VCARD</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>FN</td>
|
||||
<td>Optional</td>
|
||||
<td>Required</td>
|
||||
<td>Required</td>
|
||||
<td>The formatted name string associated with the vCard object.</td>
|
||||
<td>FN:Dr. John Doe</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>N</td>
|
||||
<td>Required</td>
|
||||
<td>Required</td>
|
||||
<td>Optional</td>
|
||||
<td>A structured representation of the name of the person, place or thing associated with the vCard object. Structure recognizes, in order separated by semicolons: Family Name, Given Name, Additional/Middle Names, Honorific Prefixes, and Honorific Suffixes[3]</td>
|
||||
<td>N:Doe;John;;Dr;</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>NAME</td>
|
||||
<td>Undefined</td>
|
||||
<td>Optional</td>
|
||||
<td>Undefined</td>
|
||||
<td>Provides a textual representation of the SOURCE property.</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>NICKNAME</td>
|
||||
<td>Undefined</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>One or more descriptive/familiar names for the object represented by this vCard.</td>
|
||||
<td>NICKNAME:Jon,Johnny</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="6">PHOTO</td>
|
||||
<td rowspan="6">Optional</td>
|
||||
<td rowspan="6">Optional</td>
|
||||
<td rowspan="6">Optional</td>
|
||||
<td rowspan="6">An image or photograph of the individual associated with the vCard. It may point to an external URL or may be embedded in the vCard as a Base64 encoded block of text.</td>
|
||||
<td>2.1: PHOTO;JPEG:http://example.com/photo.jpg</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2.1: PHOTO;JPEG;ENCODING=BASE64:[base64-data]</td>
|
||||
</tr>
|
||||
<tr><td>3.0: PHOTO;TYPE=JPEG;VALUE=URI:http://example.com/photo.jpg</td>
|
||||
</tr>
|
||||
<tr><td>3.0: PHOTO;TYPE=JPEG;ENCODING=b:[base64-data]</td>
|
||||
</tr>
|
||||
<tr><td>4.0: PHOTO;MEDIATYPE=image/jpeg:http://example.com/photo.jpg</td>
|
||||
</tr>
|
||||
<tr><td>4.0: PHOTO;ENCODING=BASE64;TYPE=JPEG:[base64-data]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>TEL</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>The canonical number string for a telephone number for telephony communication with the vCard object.</td>
|
||||
<td>TEL;TYPE=cell:(123) 555-5832</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>TITLE</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Specifies the job title, functional position or function of the individual associated with the vCard object within an organization.</td>
|
||||
<td>TITLE:V.P. Research and Development</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>VERSION</td>
|
||||
<td>Required</td>
|
||||
<td>Required</td>
|
||||
<td>Required</td>
|
||||
<td>The version of the vCard specification. In version 4.0, this must come right after the BEGIN property.</td>
|
||||
<td>VERSION:3.0</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Not implemented yet ❌ </h3>
|
||||
<table>
|
||||
<tr>
|
||||
<td rowspan="2"><b>Name</b></td>
|
||||
<td colspan="3"><b>Property presence</b></td>
|
||||
<td rowspan="2"><b>Description</b></td>
|
||||
<td rowspan="2"><b>Example</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>v. 2.1</b></td>
|
||||
<td><b>v. 3.0</b></td>
|
||||
<td><b>v. 4.0</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>AGENT</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Undefined</td>
|
||||
<td>Information about another person who will act on behalf of the vCard object. Typically this would be an area administrator, assistant, or secretary for the individual. Can be either a URL or an embedded vCard.</td>
|
||||
<td>AGENT:http://mi6.gov.uk/007</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ANNIVERSARY</td>
|
||||
<td>Undefined</td>
|
||||
<td>Undefined</td>
|
||||
<td>Optional</td>
|
||||
<td>Defines the person's anniversary.</td>
|
||||
<td>ANNIVERSARY:19901021</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>BDAY</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Date of birth of the individual associated with the vCard.</td>
|
||||
<td>BDAY:19700310</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>CALADRURI</td>
|
||||
<td>Undefined</td>
|
||||
<td>Undefined</td>
|
||||
<td>Optional</td>
|
||||
<td>A URL to use for sending a scheduling request to the person's calendar.</td>
|
||||
<td>CALADRURI:http://example.com/calendar/jdoe</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>CALURI</td>
|
||||
<td>Undefined</td>
|
||||
<td>Undefined</td>
|
||||
<td>Optional</td>
|
||||
<td>A URL to the person's calendar.</td>
|
||||
<td>CALURI:http://example.com/calendar/jdoe</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>CATEGORIES</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>A list of "tags" that can be used to describe the object represented by this vCard.</td>
|
||||
<td>CATEGORIES:swimmer,biker</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>CLASS</td>
|
||||
<td>Undefined</td>
|
||||
<td>Optional</td>
|
||||
<td>Undefined</td>
|
||||
<td>Describes the sensitivity of the information in the vCard.</td>
|
||||
<td>CLASS:public</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>CLIENTPIDMAP</td>
|
||||
<td>Undefined</td>
|
||||
<td>Undefined</td>
|
||||
<td>Optional</td>
|
||||
<td>Used for synchronizing different revisions of the same vCard.</td>
|
||||
<td>CLIENTPIDMAP:1;urn:uuid:3df403f4-5924-4bb7-b077-3c711d9eb34b</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>FBURL</td>
|
||||
<td>Undefined</td>
|
||||
<td>Undefined</td>
|
||||
<td>Optional</td>
|
||||
<td>Defines a URL that shows when the person is "free" or "busy" on their calendar.</td>
|
||||
<td>FBURL:http://example.com/fb/jdoe</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>GENDER</td>
|
||||
<td>Undefined</td>
|
||||
<td>Undefined</td>
|
||||
<td>Optional</td>
|
||||
<td>Defines the person's gender.</td>
|
||||
<td>GENDER:F</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>GEO</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Specifies a latitude and longitude.</td>
|
||||
<td>2.1, 3.0: GEO:39.95;-75.1667 <br>4.0: GEO:geo:39.95,-75.1667</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>IMPP</td>
|
||||
<td>Undefined</td>
|
||||
<td>Maybe</td>
|
||||
<td>Optional</td>
|
||||
<td>"Defines an instant messenger handle. <br>This property was introduced in a separate RFC when the latest vCard version was 3.0. Therefore, 3.0 vCards might use this property without otherwise declaring it."</td>
|
||||
<td>IMPP:aim:johndoe@aol.com</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="6">KEY</td>
|
||||
<td rowspan="6">Optional</td>
|
||||
<td rowspan="6">Optional</td>
|
||||
<td rowspan="6">Optional</td>
|
||||
<td rowspan="6">The public encryption key associated with the vCard object. It may point to an external URL, may be plain text, or may be embedded in the vCard as a Base64 encoded block of text.</td>
|
||||
<td>2.1: KEY;PGP:http://example.com/key.pgp</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2.1: KEY;PGP;ENCODING=BASE64:[base64-data]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3.0: KEY;TYPE=PGP:http://example.com/key.pgp</td>
|
||||
</tr>
|
||||
<tr><td>3.0: KEY;TYPE=PGP;ENCODING=b:[base64-data]</td>
|
||||
</tr>
|
||||
<tr><td>4.0: KEY;MEDIATYPE=application/pgp-keys:http://example.com/key.pgp</td>
|
||||
</tr>
|
||||
<tr><td>4.0: KEY:data:application/pgp-keys;base64,[base64-data]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KIND</td>
|
||||
<td>Undefined</td>
|
||||
<td>Undefined</td>
|
||||
<td>Optional</td>
|
||||
<td>Defines the type of entity that this vCard represents: 'application', 'individual', 'group', 'location' or 'organization'; 'x-*' values may be used for experimental purposes.[1][2]</td>
|
||||
<td>KIND:individual</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>LABEL</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Incorporated without</td>
|
||||
<td>Represents the actual text that should be put on the mailing label when delivering a physical package to the person/object associated with the vCard (related to the ADR property).<br>Not supported in version 4.0. Instead, this information is stored in the LABEL parameter of the ADR property. Example: ADR;TYPE=home;LABEL="123 Main St\nNew York, NY 12345":;;123 Main St;New York;NY;12345;USA</td>
|
||||
<td>LABEL;TYPE=HOME:123 Main St.\nSpringfield, IL 12345\nUSA</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>LANG</td>
|
||||
<td>Undefined</td>
|
||||
<td>Undefined</td>
|
||||
<td>Optional</td>
|
||||
<td>Defines a language that the person speaks.</td>
|
||||
<td>LANG:fr-CA</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="6">LOGO</td>
|
||||
<td rowspan="6">Optional</td>
|
||||
<td rowspan="6">Optional</td>
|
||||
<td rowspan="6">Optional</td>
|
||||
<td rowspan="6">An image or graphic of the logo of the organization that is associated with the individual to which the vCard belongs. It may point to an external URL or may be embedded in the vCard as a Base64 encoded block of text.</td>
|
||||
<td>2.1: LOGO;PNG:http://example.com/logo.png</td>
|
||||
</tr>
|
||||
<tr> <td>2.1: LOGO;PNG;ENCODING=BASE64:[base64-data]</td>
|
||||
</tr>
|
||||
<tr><td>3.0: LOGO;TYPE=PNG:http://example.com/logo.png</td>
|
||||
</tr>
|
||||
<tr><td>3.0: LOGO;TYPE=PNG;ENCODING=b:[base64-data]</td>
|
||||
</tr>
|
||||
<tr><td>4.0: LOGO;MEDIATYPE=image/png:http://example.com/logo.png</td>
|
||||
</tr>
|
||||
<tr><td>4.0: LOGO;ENCODING=BASE64;TYPE=PNG:[base64-data]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>MAILER</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Undefined</td>
|
||||
<td>Type of email program used.</td>
|
||||
<td>MAILER:Thunderbird</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>MEMBER</td>
|
||||
<td>Undefined</td>
|
||||
<td>Undefined</td>
|
||||
<td>Optional</td>
|
||||
<td>Defines a member that is part of the group that this vCard represents. Acceptable values include:
|
||||
<ul><li>a "mailto:" URL containing an email address</li>
|
||||
<li>a UID which references the member's own vCard</li>
|
||||
</ul>
|
||||
The KIND property must be set to "group" in order to use this property.
|
||||
</td>
|
||||
<td>MEMBER:urn:uuid:03a0e51f-d1aa-4385-8a53-e29025acd8af</td>
|
||||
</tr><tr>
|
||||
<td>NOTE</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Specifies supplemental information or a comment that is associated with the vCard.</td>
|
||||
<td>NOTE:I am proficient in Tiger-Crane Style,\nand I am more than proficient in the exquisite art of the Samurai sword.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ORG</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>The name and optionally the unit(s) of the organization associated with the vCard object. This property is based on the X.520 Organization Name attribute and the X.520 Organization Unit attribute.</td>
|
||||
<td>ORG:Google;GMail Team;Spam Detection Squad</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PRODID</td>
|
||||
<td>Undefined</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>The identifier for the product that created the vCard object.</td>
|
||||
<td>PRODID:-//ONLINE DIRECTORY//NONSGML Version 1//EN</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PROFILE</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Undefined</td>
|
||||
<td>States that the vCard is a vCard.</td>
|
||||
<td>PROFILE:VCARD</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>RELATED</td>
|
||||
<td>Undefined</td>
|
||||
<td>Undefined</td>
|
||||
<td>Optional</td>
|
||||
<td>Another entity that the person is related to. Acceptable values include:
|
||||
<ul>
|
||||
<li>a "mailto:" URL containing an email address</li>
|
||||
<li>a UID which references the person's own vCard</li>
|
||||
</ul>
|
||||
</td>
|
||||
<td>RELATED;TYPE=friend:urn:uuid:03a0e51f-d1aa-4385-8a53-e29025acd8af</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>REV</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>A timestamp for the last time the vCard was updated.</td>
|
||||
<td>REV:20121201T134211Z</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ROLE</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>The role, occupation, or business category of the vCard object within an organization.</td>
|
||||
<td>ROLE:Executive</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>SORT-STRING</td>
|
||||
<td>Undefined</td>
|
||||
<td>Optional</td>
|
||||
<td>Incorporated without</td>
|
||||
<td>Defines a string that should be used when an application sorts this vCard in some way.<br/>Not supported in version 4.0. Instead, this information is stored in the SORT-AS parameter of the N and/or ORG properties.</td>
|
||||
<td>SORT-STRING:Doe</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="6">SOUND</td>
|
||||
<td rowspan="6">Optional</td>
|
||||
<td rowspan="6">Optional</td>
|
||||
<td rowspan="6">Optional</td>
|
||||
<td rowspan="6">By default, if this property is not grouped with other properties it specifies the pronunciation of the FN property of the vCard object. It may point to an external URL or may be embedded in the vCard as a Base64 encoded block of text.</td>
|
||||
<td>2.1: SOUND;OGG:http://example.com/sound.ogg</td>
|
||||
</tr>
|
||||
<tr><td>2.1: SOUND;OGG;ENCODING=BASE64:[base64-data]</td>
|
||||
</tr>
|
||||
<tr><td>3.0: SOUND;TYPE=OGG:http://example.com/sound.ogg</td>
|
||||
</tr>
|
||||
<tr><td>3.0: SOUND;TYPE=OGG;ENCODING=b:[base64-data]</td>
|
||||
</tr>
|
||||
<tr><td>4.0: SOUND;MEDIATYPE=audio/ogg:http://example.com/sound.ogg</td>
|
||||
</tr>
|
||||
<tr><td>4.0: SOUND:data:audio/ogg;base64,[base64-data]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>SOURCE</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>A URL that can be used to get the latest version of this vCard.</td>
|
||||
<td>SOURCE:http://johndoe.com/vcard.vcf</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>TZ</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>The time zone of the vCard object.</td>
|
||||
<td>2.1, 3.0: TZ:-0500 <br/>4.0: TZ:America/New_York</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>UID</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Specifies a value that represents a persistent, globally unique identifier associated with the object.</td>
|
||||
<td>UID:urn:uuid:da418720-3754-4631-a169-db89a02b831b</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>URL</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>Optional</td>
|
||||
<td>A URL pointing to a website that represents the person in some way.</td>
|
||||
<td>URL:http://www.johndoe.com</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>XML</td>
|
||||
<td>Undefined</td>
|
||||
<td>Undefined</td>
|
||||
<td>Optional</td>
|
||||
<td>Any XML data that is attached to the vCard. This is used if the vCard was encoded in XML (xCard standard) and the XML document contained elements which are not part of the xCard standard.</td>
|
||||
<td>XML:<b>Not an xCard XML element</b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
78
vCardEditor/Libs/QRCoder/ASCIIQRCode.cs
Normal file
78
vCardEditor/Libs/QRCoder/ASCIIQRCode.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using static QRCoder.QRCodeGenerator;
|
||||
|
||||
namespace QRCoder
|
||||
{
|
||||
public class AsciiQRCode : AbstractQRCode, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor without params to be used in COM Objects connections
|
||||
/// </summary>
|
||||
public AsciiQRCode() { }
|
||||
|
||||
public AsciiQRCode(QRCodeData data) : base(data) { }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a strings that contains the resulting QR code as ASCII chars.
|
||||
/// </summary>
|
||||
/// <param name="repeatPerModule">Number of repeated darkColorString/whiteSpaceString per module.</param>
|
||||
/// <param name="darkColorString">String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.</param>
|
||||
/// <param name="whiteSpaceString">String for use as white modules (whitespace). In case of string make sure darkColorString has the same length.</param>
|
||||
/// <param name="endOfLine">End of line separator. (Default: \n)</param>
|
||||
/// <returns></returns>
|
||||
public string GetGraphic(int repeatPerModule, string darkColorString = "██", string whiteSpaceString = " ", bool drawQuietZones = true, string endOfLine = "\n")
|
||||
{
|
||||
return string.Join(endOfLine, GetLineByLineGraphic(repeatPerModule, darkColorString, whiteSpaceString, drawQuietZones));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns an array of strings that contains each line of the resulting QR code as ASCII chars.
|
||||
/// </summary>
|
||||
/// <param name="repeatPerModule">Number of repeated darkColorString/whiteSpaceString per module.</param>
|
||||
/// <param name="darkColorString">String for use as dark color modules. In case of string make sure whiteSpaceString has the same length.</param>
|
||||
/// <param name="whiteSpaceString">String for use as white modules (whitespace). In case of string make sure darkColorString has the same length.</param>
|
||||
/// <returns></returns>
|
||||
public string[] GetLineByLineGraphic(int repeatPerModule, string darkColorString = "██", string whiteSpaceString = " ", bool drawQuietZones = true)
|
||||
{
|
||||
var qrCode = new List<string>();
|
||||
//We need to adjust the repeatPerModule based on number of characters in darkColorString
|
||||
//(we assume whiteSpaceString has the same number of characters)
|
||||
//to keep the QR code as square as possible.
|
||||
var quietZonesModifier = (drawQuietZones ? 0 : 8);
|
||||
var quietZonesOffset = (int)(quietZonesModifier * 0.5);
|
||||
var adjustmentValueForNumberOfCharacters = darkColorString.Length / 2 != 1 ? darkColorString.Length / 2 : 0;
|
||||
var verticalNumberOfRepeats = repeatPerModule + adjustmentValueForNumberOfCharacters;
|
||||
var sideLength = (QrCodeData.ModuleMatrix.Count - quietZonesModifier) * verticalNumberOfRepeats;
|
||||
for (var y = 0; y < sideLength; y++)
|
||||
{
|
||||
var lineBuilder = new StringBuilder();
|
||||
for (var x = 0; x < QrCodeData.ModuleMatrix.Count - quietZonesModifier; x++)
|
||||
{
|
||||
var module = QrCodeData.ModuleMatrix[x + quietZonesOffset][((y + verticalNumberOfRepeats) / verticalNumberOfRepeats - 1)+quietZonesOffset];
|
||||
for (var i = 0; i < repeatPerModule; i++)
|
||||
{
|
||||
lineBuilder.Append(module ? darkColorString : whiteSpaceString);
|
||||
}
|
||||
}
|
||||
qrCode.Add(lineBuilder.ToString());
|
||||
}
|
||||
return qrCode.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class AsciiQRCodeHelper
|
||||
{
|
||||
public static string GetQRCode(string plainText, int pixelsPerModule, string darkColorString, string whiteSpaceString, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, string endOfLine = "\n", bool drawQuietZones = true)
|
||||
{
|
||||
using (var qrGenerator = new QRCodeGenerator())
|
||||
using (var qrCodeData = qrGenerator.CreateQrCode(plainText, eccLevel, forceUtf8, utf8BOM, eciMode, requestedVersion))
|
||||
using (var qrCode = new AsciiQRCode(qrCodeData))
|
||||
return qrCode.GetGraphic(pixelsPerModule, darkColorString, whiteSpaceString, drawQuietZones, endOfLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
28
vCardEditor/Libs/QRCoder/AbstractQRCode.cs
Normal file
28
vCardEditor/Libs/QRCoder/AbstractQRCode.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace QRCoder
|
||||
{
|
||||
public abstract class AbstractQRCode
|
||||
{
|
||||
protected QRCodeData QrCodeData { get; set; }
|
||||
|
||||
protected AbstractQRCode() {
|
||||
}
|
||||
|
||||
protected AbstractQRCode(QRCodeData data) {
|
||||
this.QrCodeData = data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set a QRCodeData object that will be used to generate QR code. Used in COM Objects connections
|
||||
/// </summary>
|
||||
/// <param name="data">Need a QRCodeData object generated by QRCodeGenerator.CreateQrCode()</param>
|
||||
virtual public void SetQRCodeData(QRCodeData data) {
|
||||
this.QrCodeData = data;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.QrCodeData?.Dispose();
|
||||
this.QrCodeData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
298
vCardEditor/Libs/QRCoder/ArtQRCode.cs
Normal file
298
vCardEditor/Libs/QRCoder/ArtQRCode.cs
Normal file
@@ -0,0 +1,298 @@
|
||||
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using static QRCoder.ArtQRCode;
|
||||
using static QRCoder.QRCodeGenerator;
|
||||
|
||||
// pull request raised to extend library used.
|
||||
namespace QRCoder
|
||||
{
|
||||
#if NET6_0_WINDOWS
|
||||
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
|
||||
#endif
|
||||
public class ArtQRCode : AbstractQRCode, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor without params to be used in COM Objects connections
|
||||
/// </summary>
|
||||
public ArtQRCode() { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates new ArtQrCode object
|
||||
/// </summary>
|
||||
/// <param name="data">QRCodeData generated by the QRCodeGenerator</param>
|
||||
public ArtQRCode(QRCodeData data) : base(data) { }
|
||||
|
||||
/// <summary>
|
||||
/// Renders an art-style QR code with dots as modules. (With default settings: DarkColor=Black, LightColor=White, Background=Transparent, QuietZone=true)
|
||||
/// </summary>
|
||||
/// <param name="pixelsPerModule">Amount of px each dark/light module of the QR code shall take place in the final QR code image</param>
|
||||
/// <returns>QRCode graphic as bitmap</returns>
|
||||
public Bitmap GetGraphic(int pixelsPerModule)
|
||||
{
|
||||
return this.GetGraphic(pixelsPerModule, Color.Black, Color.White, Color.Transparent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders an art-style QR code with dots as modules and a background image (With default settings: DarkColor=Black, LightColor=White, Background=Transparent, QuietZone=true)
|
||||
/// </summary>
|
||||
/// <param name="backgroundImage">A bitmap object that will be used as background picture</param>
|
||||
/// <returns>QRCode graphic as bitmap</returns>
|
||||
public Bitmap GetGraphic(Bitmap backgroundImage = null)
|
||||
{
|
||||
return this.GetGraphic(10, Color.Black, Color.White, Color.Transparent, backgroundImage: backgroundImage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders an art-style QR code with dots as modules and various user settings
|
||||
/// </summary>
|
||||
/// <param name="pixelsPerModule">Amount of px each dark/light module of the QR code shall take place in the final QR code image</param>
|
||||
/// <param name="darkColor">Color of the dark modules</param>
|
||||
/// <param name="lightColor">Color of the light modules</param>
|
||||
/// <param name="backgroundColor">Color of the background</param>
|
||||
/// <param name="backgroundImage">A bitmap object that will be used as background picture</param>
|
||||
/// <param name="pixelSizeFactor">Value between 0.0 to 1.0 that defines how big the module dots are. The bigger the value, the less round the dots will be.</param>
|
||||
/// <param name="drawQuietZones">If true a white border is drawn around the whole QR Code</param>
|
||||
/// <param name="quietZoneRenderingStyle">Style of the quiet zones</param>
|
||||
/// <param name="backgroundImageStyle">Style of the background image (if set). Fill=spanning complete graphic; DataAreaOnly=Don't paint background into quietzone</param>
|
||||
/// <param name="finderPatternImage">Optional image that should be used instead of the default finder patterns</param>
|
||||
/// <returns>QRCode graphic as bitmap</returns>
|
||||
public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, Color backgroundColor, Bitmap backgroundImage = null, double pixelSizeFactor = 0.8,
|
||||
bool drawQuietZones = true, QuietZoneStyle quietZoneRenderingStyle = QuietZoneStyle.Dotted,
|
||||
BackgroundImageStyle backgroundImageStyle = BackgroundImageStyle.DataAreaOnly, Bitmap finderPatternImage = null)
|
||||
{
|
||||
if (pixelSizeFactor > 1)
|
||||
throw new Exception("The parameter pixelSize must be between 0 and 1. (0-100%)");
|
||||
int pixelSize = (int)Math.Min(pixelsPerModule, Math.Floor(pixelsPerModule / pixelSizeFactor));
|
||||
|
||||
var numModules = QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : 8);
|
||||
var offset = (drawQuietZones ? 0 : 4);
|
||||
var size = numModules * pixelsPerModule;
|
||||
|
||||
var bitmap = new Bitmap(size, size);
|
||||
|
||||
using (var graphics = Graphics.FromImage(bitmap))
|
||||
{
|
||||
using (var lightBrush = new SolidBrush(lightColor))
|
||||
{
|
||||
using (var darkBrush = new SolidBrush(darkColor))
|
||||
{
|
||||
// make background transparent
|
||||
using (var brush = new SolidBrush(backgroundColor))
|
||||
graphics.FillRectangle(brush, new Rectangle(0, 0, size, size));
|
||||
//Render background if set
|
||||
if (backgroundImage != null)
|
||||
{
|
||||
if (backgroundImageStyle == BackgroundImageStyle.Fill)
|
||||
graphics.DrawImage(Resize(backgroundImage, size), 0, 0);
|
||||
else if (backgroundImageStyle == BackgroundImageStyle.DataAreaOnly)
|
||||
{
|
||||
var bgOffset = 4 - offset;
|
||||
graphics.DrawImage(Resize(backgroundImage, size - (2 * bgOffset * pixelsPerModule)), 0 + (bgOffset * pixelsPerModule), (bgOffset * pixelsPerModule));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var darkModulePixel = MakeDotPixel(pixelsPerModule, pixelSize, darkBrush);
|
||||
var lightModulePixel = MakeDotPixel(pixelsPerModule, pixelSize, lightBrush);
|
||||
|
||||
for (var x = 0; x < numModules; x += 1)
|
||||
{
|
||||
for (var y = 0; y < numModules; y += 1)
|
||||
{
|
||||
var rectangleF = new Rectangle(x * pixelsPerModule, y * pixelsPerModule, pixelsPerModule, pixelsPerModule);
|
||||
|
||||
var pixelIsDark = this.QrCodeData.ModuleMatrix[offset + y][offset + x];
|
||||
var solidBrush = pixelIsDark ? darkBrush : lightBrush;
|
||||
var pixelImage = pixelIsDark ? darkModulePixel : lightModulePixel;
|
||||
|
||||
if (!IsPartOfFinderPattern(x, y, numModules, offset))
|
||||
if (drawQuietZones && quietZoneRenderingStyle == QuietZoneStyle.Flat && IsPartOfQuietZone(x, y, numModules))
|
||||
graphics.FillRectangle(solidBrush, rectangleF);
|
||||
else
|
||||
graphics.DrawImage(pixelImage, rectangleF);
|
||||
else if (finderPatternImage == null)
|
||||
graphics.FillRectangle(solidBrush, rectangleF);
|
||||
}
|
||||
}
|
||||
if (finderPatternImage != null)
|
||||
{
|
||||
var finderPatternSize = 7 * pixelsPerModule;
|
||||
graphics.DrawImage(finderPatternImage, new Rectangle(0, 0, finderPatternSize, finderPatternSize));
|
||||
graphics.DrawImage(finderPatternImage, new Rectangle(size - finderPatternSize, 0, finderPatternSize, finderPatternSize));
|
||||
graphics.DrawImage(finderPatternImage, new Rectangle(0, size - finderPatternSize, finderPatternSize, finderPatternSize));
|
||||
}
|
||||
graphics.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the pixelSize is bigger than the pixelsPerModule or may end up filling the Module making a traditional QR code.
|
||||
/// </summary>
|
||||
/// <param name="pixelsPerModule">Pixels used per module rendered</param>
|
||||
/// <param name="pixelSize">Size of the dots</param>
|
||||
/// <param name="brush">Color of the pixels</param>
|
||||
/// <returns></returns>
|
||||
private Bitmap MakeDotPixel(int pixelsPerModule, int pixelSize, SolidBrush brush)
|
||||
{
|
||||
// draw a dot
|
||||
var bitmap = new Bitmap(pixelSize, pixelSize);
|
||||
using (var graphics = Graphics.FromImage(bitmap))
|
||||
{
|
||||
graphics.FillEllipse(brush, new Rectangle(0, 0, pixelSize, pixelSize));
|
||||
graphics.Save();
|
||||
}
|
||||
|
||||
var pixelWidth = Math.Min(pixelsPerModule, pixelSize);
|
||||
var margin = Math.Max((pixelsPerModule - pixelWidth) / 2, 0);
|
||||
|
||||
// center the dot in the module and crop to stay the right size.
|
||||
var cropped = new Bitmap(pixelsPerModule, pixelsPerModule);
|
||||
using (var graphics = Graphics.FromImage(cropped))
|
||||
{
|
||||
graphics.DrawImage(bitmap, new Rectangle(margin, margin, pixelWidth, pixelWidth),
|
||||
new RectangleF(((float)pixelSize - pixelWidth) / 2, ((float)pixelSize - pixelWidth) / 2, pixelWidth, pixelWidth),
|
||||
GraphicsUnit.Pixel);
|
||||
graphics.Save();
|
||||
}
|
||||
|
||||
return cropped;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a given module(-position) is part of the quietzone of a QR code
|
||||
/// </summary>
|
||||
/// <param name="x">X position</param>
|
||||
/// <param name="y">Y position</param>
|
||||
/// <param name="numModules">Total number of modules per row</param>
|
||||
/// <returns>true, if position is part of quiet zone</returns>
|
||||
private bool IsPartOfQuietZone(int x, int y, int numModules)
|
||||
{
|
||||
return
|
||||
x < 4 || //left
|
||||
y < 4 || //top
|
||||
x > numModules - 5 || //right
|
||||
y > numModules - 5; //bottom
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a given module(-position) is part of one of the three finder patterns of a QR code
|
||||
/// </summary>
|
||||
/// <param name="x">X position</param>
|
||||
/// <param name="y">Y position</param>
|
||||
/// <param name="numModules">Total number of modules per row</param>
|
||||
/// <param name="offset">Offset in modules (usually depending on drawQuietZones parameter)</param>
|
||||
/// <returns>true, if position is part of any finder pattern</returns>
|
||||
private bool IsPartOfFinderPattern(int x, int y, int numModules, int offset)
|
||||
{
|
||||
var cornerSize = 11 - offset;
|
||||
var outerLimitLow = (numModules - cornerSize - 1);
|
||||
var outerLimitHigh = outerLimitLow + 8;
|
||||
var invertedOffset = 4 - offset;
|
||||
return
|
||||
(x >= invertedOffset && x < cornerSize && y >= invertedOffset && y < cornerSize) || //Top-left finder pattern
|
||||
(x > outerLimitLow && x < outerLimitHigh && y >= invertedOffset && y < cornerSize) || //Top-right finder pattern
|
||||
(x >= invertedOffset && x < cornerSize && y > outerLimitLow && y < outerLimitHigh); //Bottom-left finder pattern
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resize to a square bitmap, but maintain the aspect ratio by padding transparently.
|
||||
/// </summary>
|
||||
/// <param name="image"></param>
|
||||
/// <param name="newSize"></param>
|
||||
/// <returns>Resized image as bitmap</returns>
|
||||
private Bitmap Resize(Bitmap image, int newSize)
|
||||
{
|
||||
if (image == null) return null;
|
||||
|
||||
float scale = Math.Min((float)newSize / image.Width, (float)newSize / image.Height);
|
||||
var scaledWidth = (int)(image.Width * scale);
|
||||
var scaledHeight = (int)(image.Height * scale);
|
||||
var offsetX = (newSize - scaledWidth) / 2;
|
||||
var offsetY = (newSize - scaledHeight) / 2;
|
||||
|
||||
var scaledImage = new Bitmap(image, new Size(scaledWidth, scaledHeight));
|
||||
|
||||
var bm = new Bitmap(newSize, newSize);
|
||||
|
||||
using (Graphics graphics = Graphics.FromImage(bm))
|
||||
{
|
||||
using (var brush = new SolidBrush(Color.Transparent))
|
||||
{
|
||||
graphics.FillRectangle(brush, new Rectangle(0, 0, newSize, newSize));
|
||||
|
||||
graphics.InterpolationMode = InterpolationMode.High;
|
||||
graphics.CompositingQuality = CompositingQuality.HighQuality;
|
||||
graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
|
||||
graphics.DrawImage(scaledImage, new Rectangle(offsetX, offsetY, scaledWidth, scaledHeight));
|
||||
}
|
||||
}
|
||||
return bm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines how the quiet zones shall be rendered.
|
||||
/// </summary>
|
||||
public enum QuietZoneStyle
|
||||
{
|
||||
Dotted,
|
||||
Flat
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines how the background image (if set) shall be rendered.
|
||||
/// </summary>
|
||||
public enum BackgroundImageStyle
|
||||
{
|
||||
Fill,
|
||||
DataAreaOnly
|
||||
}
|
||||
}
|
||||
|
||||
#if NET6_0_WINDOWS
|
||||
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
|
||||
#endif
|
||||
public static class ArtQRCodeHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper function to create an ArtQRCode graphic with a single function call
|
||||
/// </summary>
|
||||
/// <param name="plainText">Text/payload to be encoded inside the QR code</param>
|
||||
/// <param name="pixelsPerModule">Amount of px each dark/light module of the QR code shall take place in the final QR code image</param>
|
||||
/// <param name="darkColor">Color of the dark modules</param>
|
||||
/// <param name="lightColor">Color of the light modules</param>
|
||||
/// <param name="backgroundColor">Color of the background</param>
|
||||
/// <param name="eccLevel">The level of error correction data</param>
|
||||
/// <param name="forceUtf8">Shall the generator be forced to work in UTF-8 mode?</param>
|
||||
/// <param name="utf8BOM">Should the byte-order-mark be used?</param>
|
||||
/// <param name="eciMode">Which ECI mode shall be used?</param>
|
||||
/// <param name="requestedVersion">Set fixed QR code target version.</param>
|
||||
/// <param name="backgroundImage">A bitmap object that will be used as background picture</param>
|
||||
/// <param name="pixelSizeFactor">Value between 0.0 to 1.0 that defines how big the module dots are. The bigger the value, the less round the dots will be.</param>
|
||||
/// <param name="drawQuietZones">If true a white border is drawn around the whole QR Code</param>
|
||||
/// <param name="quietZoneRenderingStyle">Style of the quiet zones</param>
|
||||
/// <param name="backgroundImageStyle">Style of the background image (if set). Fill=spanning complete graphic; DataAreaOnly=Don't paint background into quietzone</param>
|
||||
/// <param name="finderPatternImage">Optional image that should be used instead of the default finder patterns</param>
|
||||
/// <returns>QRCode graphic as bitmap</returns>
|
||||
public static Bitmap GetQRCode(string plainText, int pixelsPerModule, Color darkColor, Color lightColor, Color backgroundColor, ECCLevel eccLevel, bool forceUtf8 = false,
|
||||
bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, Bitmap backgroundImage = null, double pixelSizeFactor = 0.8,
|
||||
bool drawQuietZones = true, QuietZoneStyle quietZoneRenderingStyle = QuietZoneStyle.Flat,
|
||||
BackgroundImageStyle backgroundImageStyle = BackgroundImageStyle.DataAreaOnly, Bitmap finderPatternImage = null)
|
||||
{
|
||||
using (var qrGenerator = new QRCodeGenerator())
|
||||
using (var qrCodeData = qrGenerator.CreateQrCode(plainText, eccLevel, forceUtf8, utf8BOM, eciMode, requestedVersion))
|
||||
using (var qrCode = new ArtQRCode(qrCodeData))
|
||||
return qrCode.GetGraphic(pixelsPerModule, darkColor, lightColor, backgroundColor, backgroundImage, pixelSizeFactor, drawQuietZones, quietZoneRenderingStyle, backgroundImageStyle, finderPatternImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
BIN
vCardEditor/Libs/QRCoder/Assets/nuget-icon.png
Normal file
BIN
vCardEditor/Libs/QRCoder/Assets/nuget-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
59
vCardEditor/Libs/QRCoder/Assets/nuget-readme.md
Normal file
59
vCardEditor/Libs/QRCoder/Assets/nuget-readme.md
Normal file
@@ -0,0 +1,59 @@
|
||||
## About
|
||||
|
||||
QRCoder is a simple library, written in C#.NET, which enables you to create QR codes. It hasn't any dependencies to other libraries and is available as .NET Framework and .NET Core PCL version on NuGet.
|
||||
|
||||
***
|
||||
|
||||
## Documentation
|
||||
|
||||
👉 *Your first place to go should be our wiki. Here you can find a detailed documentation of the QRCoder and its functions.*
|
||||
* [**QRCode Wiki**](https://github.com/codebude/QRCoder/wiki)
|
||||
* [Creator's blog (english)](http://en.code-bude.net/2013/10/17/qrcoder-an-open-source-qr-code-generator-implementation-in-csharp/)
|
||||
* [Creator's blog (german)](http://code-bude.net/2013/10/17/qrcoder-eine-open-source-qr-code-implementierung-in-csharp/)
|
||||
|
||||
### Release Notes
|
||||
The release notes for the current and all past releases can be read here: [📄 Release Notes](https://github.com/codebude/QRCoder/wiki/Release-notes)
|
||||
|
||||
## Usage / Quick start
|
||||
|
||||
You only need four lines of code, to generate and view your first QR code.
|
||||
|
||||
```csharp
|
||||
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
|
||||
using (QRCodeData qrCodeData = qrGenerator.CreateQrCode("The text which should be encoded.", QRCodeGenerator.ECCLevel.Q))
|
||||
using (QRCode qrCode = new QRCode(qrCodeData))
|
||||
{
|
||||
Bitmap qrCodeImage = qrCode.GetGraphic(20);
|
||||
}
|
||||
```
|
||||
|
||||
### Optional parameters and overloads
|
||||
|
||||
The GetGraphics-method has some more overloads. The first two enable you to set the color of the QR code graphic. One uses Color-class-types, the other HTML hex color notation.
|
||||
|
||||
```csharp
|
||||
//Set color by using Color-class types
|
||||
Bitmap qrCodeImage = qrCode.GetGraphic(20, Color.DarkRed, Color.PaleGreen, true);
|
||||
|
||||
//Set color by using HTML hex color notation
|
||||
Bitmap qrCodeImage = qrCode.GetGraphic(20, "#000ff0", "#0ff000");
|
||||
```
|
||||
|
||||
The other overload enables you to render a logo/image in the center of the QR code.
|
||||
|
||||
```csharp
|
||||
Bitmap qrCodeImage = qrCode.GetGraphic(20, Color.Black, Color.White, (Bitmap)Bitmap.FromFile("C:\\myimage.png"));
|
||||
```
|
||||
|
||||
There are a plenty of other options. So feel free to read more on that in our wiki: [Wiki: How to use QRCoder](https://github.com/codebude/QRCoder/wiki/How-to-use-QRCoder)
|
||||
|
||||
## Help & Issues
|
||||
|
||||
If you think you have found a bug or have new ideas or feature requests, then feel free to open a new issue: https://github.com/codebude/QRCoder/issues
|
||||
|
||||
In case you have a question about using the library (and couldn't find an answer in our wiki), feel free to open a new question/discussion: https://github.com/codebude/QRCoder/discussions
|
||||
|
||||
|
||||
## Legal information and credits
|
||||
|
||||
QRCoder is a project by [Raffael Herrmann](https://raffaelherrmann.de) and was first released in 10/2013. It's licensed under the [MIT license](https://github.com/codebude/QRCoder/blob/master/LICENSE.txt).
|
||||
115
vCardEditor/Libs/QRCoder/Base64QRCode.cs
Normal file
115
vCardEditor/Libs/QRCoder/Base64QRCode.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using static QRCoder.Base64QRCode;
|
||||
using static QRCoder.QRCodeGenerator;
|
||||
|
||||
namespace QRCoder
|
||||
{
|
||||
#if NET6_0_WINDOWS
|
||||
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
|
||||
#endif
|
||||
public class Base64QRCode : AbstractQRCode, IDisposable
|
||||
{
|
||||
private QRCode qr;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor without params to be used in COM Objects connections
|
||||
/// </summary>
|
||||
public Base64QRCode() {
|
||||
qr = new QRCode();
|
||||
}
|
||||
|
||||
public Base64QRCode(QRCodeData data) : base(data) {
|
||||
qr = new QRCode(data);
|
||||
}
|
||||
|
||||
public override void SetQRCodeData(QRCodeData data) {
|
||||
this.qr.SetQRCodeData(data);
|
||||
}
|
||||
|
||||
public string GetGraphic(int pixelsPerModule)
|
||||
{
|
||||
return this.GetGraphic(pixelsPerModule, Color.Black, Color.White, true);
|
||||
}
|
||||
|
||||
|
||||
public string GetGraphic(int pixelsPerModule, string darkColorHtmlHex, string lightColorHtmlHex, bool drawQuietZones = true, ImageType imgType = ImageType.Png)
|
||||
{
|
||||
return this.GetGraphic(pixelsPerModule, ColorTranslator.FromHtml(darkColorHtmlHex), ColorTranslator.FromHtml(lightColorHtmlHex), drawQuietZones, imgType);
|
||||
}
|
||||
|
||||
public string GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, bool drawQuietZones = true, ImageType imgType = ImageType.Png)
|
||||
{
|
||||
var base64 = string.Empty;
|
||||
using (Bitmap bmp = qr.GetGraphic(pixelsPerModule, darkColor, lightColor, drawQuietZones))
|
||||
{
|
||||
base64 = BitmapToBase64(bmp, imgType);
|
||||
}
|
||||
return base64;
|
||||
}
|
||||
|
||||
public string GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, Bitmap icon, int iconSizePercent = 15, int iconBorderWidth = 6, bool drawQuietZones = true, ImageType imgType = ImageType.Png)
|
||||
{
|
||||
var base64 = string.Empty;
|
||||
using (Bitmap bmp = qr.GetGraphic(pixelsPerModule, darkColor, lightColor, icon, iconSizePercent, iconBorderWidth, drawQuietZones))
|
||||
{
|
||||
base64 = BitmapToBase64(bmp, imgType);
|
||||
}
|
||||
return base64;
|
||||
}
|
||||
|
||||
|
||||
private string BitmapToBase64(Bitmap bmp, ImageType imgType)
|
||||
{
|
||||
var base64 = string.Empty;
|
||||
ImageFormat iFormat;
|
||||
switch (imgType) {
|
||||
case ImageType.Png:
|
||||
iFormat = ImageFormat.Png;
|
||||
break;
|
||||
case ImageType.Jpeg:
|
||||
iFormat = ImageFormat.Jpeg;
|
||||
break;
|
||||
case ImageType.Gif:
|
||||
iFormat = ImageFormat.Gif;
|
||||
break;
|
||||
default:
|
||||
iFormat = ImageFormat.Png;
|
||||
break;
|
||||
}
|
||||
using (MemoryStream memoryStream = new MemoryStream())
|
||||
{
|
||||
bmp.Save(memoryStream, iFormat);
|
||||
base64 = Convert.ToBase64String(memoryStream.ToArray(), Base64FormattingOptions.None);
|
||||
}
|
||||
return base64;
|
||||
}
|
||||
|
||||
public enum ImageType
|
||||
{
|
||||
Gif,
|
||||
Jpeg,
|
||||
Png
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if NET6_0_WINDOWS
|
||||
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
|
||||
#endif
|
||||
public static class Base64QRCodeHelper
|
||||
{
|
||||
public static string GetQRCode(string plainText, int pixelsPerModule, string darkColorHtmlHex, string lightColorHtmlHex, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, bool drawQuietZones = true, ImageType imgType = ImageType.Png)
|
||||
{
|
||||
using (var qrGenerator = new QRCodeGenerator())
|
||||
using (var qrCodeData = qrGenerator.CreateQrCode(plainText, eccLevel, forceUtf8, utf8BOM, eciMode, requestedVersion))
|
||||
using (var qrCode = new Base64QRCode(qrCodeData))
|
||||
return qrCode.GetGraphic(pixelsPerModule, darkColorHtmlHex, lightColorHtmlHex, drawQuietZones, imgType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
125
vCardEditor/Libs/QRCoder/BitmapByteQRCode.cs
Normal file
125
vCardEditor/Libs/QRCoder/BitmapByteQRCode.cs
Normal file
@@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static QRCoder.QRCodeGenerator;
|
||||
|
||||
namespace QRCoder
|
||||
{
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class BitmapByteQRCode : AbstractQRCode, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor without params to be used in COM Objects connections
|
||||
/// </summary>
|
||||
public BitmapByteQRCode() { }
|
||||
|
||||
public BitmapByteQRCode(QRCodeData data) : base(data) { }
|
||||
|
||||
public byte[] GetGraphic(int pixelsPerModule)
|
||||
{
|
||||
return GetGraphic(pixelsPerModule, new byte[] { 0x00, 0x00, 0x00 }, new byte[] { 0xFF, 0xFF, 0xFF });
|
||||
}
|
||||
|
||||
public byte[] GetGraphic(int pixelsPerModule, string darkColorHtmlHex, string lightColorHtmlHex)
|
||||
{
|
||||
return GetGraphic(pixelsPerModule, HexColorToByteArray(darkColorHtmlHex), HexColorToByteArray(lightColorHtmlHex));
|
||||
}
|
||||
|
||||
public byte[] GetGraphic(int pixelsPerModule, byte[] darkColorRgb, byte[] lightColorRgb)
|
||||
{
|
||||
var sideLength = this.QrCodeData.ModuleMatrix.Count * pixelsPerModule;
|
||||
|
||||
var moduleDark = darkColorRgb.Reverse();
|
||||
var moduleLight = lightColorRgb.Reverse();
|
||||
|
||||
List<byte> bmp = new List<byte>();
|
||||
|
||||
//header
|
||||
bmp.AddRange(new byte[] { 0x42, 0x4D, 0x4C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00 });
|
||||
|
||||
//width
|
||||
bmp.AddRange(IntTo4Byte(sideLength));
|
||||
//height
|
||||
bmp.AddRange(IntTo4Byte(sideLength));
|
||||
|
||||
//header end
|
||||
bmp.AddRange(new byte[] { 0x01, 0x00, 0x18, 0x00 });
|
||||
|
||||
//draw qr code
|
||||
for (var x = sideLength-1; x >= 0; x = x - pixelsPerModule)
|
||||
{
|
||||
for (int pm = 0; pm < pixelsPerModule; pm++)
|
||||
{
|
||||
for (var y = 0; y < sideLength; y = y + pixelsPerModule)
|
||||
{
|
||||
var module =
|
||||
this.QrCodeData.ModuleMatrix[(x + pixelsPerModule)/pixelsPerModule - 1][(y + pixelsPerModule)/pixelsPerModule - 1];
|
||||
for (int i = 0; i < pixelsPerModule; i++)
|
||||
{
|
||||
bmp.AddRange(module ? moduleDark : moduleLight);
|
||||
}
|
||||
}
|
||||
if (sideLength%4 != 0)
|
||||
{
|
||||
for (int i = 0; i < sideLength%4; i++)
|
||||
{
|
||||
bmp.Add(0x00);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//finalize with terminator
|
||||
bmp.AddRange(new byte[] { 0x00, 0x00 });
|
||||
|
||||
return bmp.ToArray();
|
||||
}
|
||||
|
||||
private byte[] HexColorToByteArray(string colorString)
|
||||
{
|
||||
if (colorString.StartsWith("#"))
|
||||
colorString = colorString.Substring(1);
|
||||
byte[] byteColor = new byte[colorString.Length / 2];
|
||||
for (int i = 0; i < byteColor.Length; i++)
|
||||
byteColor[i] = byte.Parse(colorString.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture);
|
||||
return byteColor;
|
||||
}
|
||||
|
||||
private byte[] IntTo4Byte(int inp)
|
||||
{
|
||||
byte[] bytes = new byte[2];
|
||||
unchecked
|
||||
{
|
||||
bytes[1] = (byte)(inp >> 8);
|
||||
bytes[0] = (byte)(inp);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class BitmapByteQRCodeHelper
|
||||
{
|
||||
public static byte[] GetQRCode(string plainText, int pixelsPerModule, string darkColorHtmlHex,
|
||||
string lightColorHtmlHex, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false,
|
||||
EciMode eciMode = EciMode.Default, int requestedVersion = -1)
|
||||
{
|
||||
using (var qrGenerator = new QRCodeGenerator())
|
||||
using (
|
||||
var qrCodeData = qrGenerator.CreateQrCode(plainText, eccLevel, forceUtf8, utf8BOM, eciMode,
|
||||
requestedVersion))
|
||||
using (var qrCode = new BitmapByteQRCode(qrCodeData))
|
||||
return qrCode.GetGraphic(pixelsPerModule, darkColorHtmlHex, lightColorHtmlHex);
|
||||
}
|
||||
|
||||
public static byte[] GetQRCode(string txt, QRCodeGenerator.ECCLevel eccLevel, int size)
|
||||
{
|
||||
using (var qrGen = new QRCodeGenerator())
|
||||
using (var qrCode = qrGen.CreateQrCode(txt, eccLevel))
|
||||
using (var qrBmp = new BitmapByteQRCode(qrCode))
|
||||
return qrBmp.GetGraphic(size);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
16
vCardEditor/Libs/QRCoder/Exceptions/DataTooLongException.cs
Normal file
16
vCardEditor/Libs/QRCoder/Exceptions/DataTooLongException.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace QRCoder.Exceptions
|
||||
{
|
||||
public class DataTooLongException : Exception
|
||||
{
|
||||
public DataTooLongException(string eccLevel, string encodingMode, int maxSizeByte) : base(
|
||||
$"The given payload exceeds the maximum size of the QR code standard. The maximum size allowed for the choosen paramters (ECC level={eccLevel}, EncodingMode={encodingMode}) is {maxSizeByte} byte."
|
||||
){}
|
||||
|
||||
public DataTooLongException(string eccLevel, string encodingMode, int version, int maxSizeByte) : base(
|
||||
$"The given payload exceeds the maximum size of the QR code standard. The maximum size allowed for the choosen paramters (ECC level={eccLevel}, EncodingMode={encodingMode}, FixedVersion={version}) is {maxSizeByte} byte."
|
||||
)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
52
vCardEditor/Libs/QRCoder/Extensions/StringValueAttribute.cs
Normal file
52
vCardEditor/Libs/QRCoder/Extensions/StringValueAttribute.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace QRCoder.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to represent a string value for a value in an enum
|
||||
/// </summary>
|
||||
public class StringValueAttribute : Attribute
|
||||
{
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Holds the alue in an enum
|
||||
/// </summary>
|
||||
public string StringValue { get; protected set; }
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Init a StringValue Attribute
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public StringValueAttribute(string value)
|
||||
{
|
||||
this.StringValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Will get the string value for a given enum's value
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetStringValue(this Enum value)
|
||||
{
|
||||
#if NETSTANDARD1_3
|
||||
var fieldInfo = value.GetType().GetRuntimeField(value.ToString());
|
||||
#else
|
||||
var fieldInfo = value.GetType().GetField(value.ToString());
|
||||
#endif
|
||||
var attr = fieldInfo.GetCustomAttributes(typeof(StringValueAttribute), false) as StringValueAttribute[];
|
||||
return attr.Length > 0 ? attr[0].StringValue : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace QRCoder.Framework4._0Methods
|
||||
{
|
||||
class Stream4Methods
|
||||
{
|
||||
public static void CopyTo(System.IO.Stream input, System.IO.Stream output)
|
||||
{
|
||||
byte[] buffer = new byte[16 * 1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
output.Write(buffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
|
||||
namespace QRCoder
|
||||
{
|
||||
internal static class String40Methods
|
||||
{
|
||||
/// <summary>
|
||||
/// The IsNullOrWhiteSpace method from Framework4.0
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// <c>true</c> if the <paramref name="value"/> is null or white space; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
public static bool IsNullOrWhiteSpace(String value)
|
||||
{
|
||||
if (value == null) return true;
|
||||
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
{
|
||||
if (!Char.IsWhiteSpace(value[i])) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string ReverseString(string str)
|
||||
{
|
||||
char[] chars = str.ToCharArray();
|
||||
char[] result = new char[chars.Length];
|
||||
for (int i = 0, j = str.Length - 1; i < str.Length; i++, j--)
|
||||
{
|
||||
result[i] = chars[j];
|
||||
}
|
||||
return new string(result);
|
||||
}
|
||||
|
||||
public static bool IsAllDigit(string str)
|
||||
{
|
||||
foreach (var c in str)
|
||||
{
|
||||
if (!char.IsDigit(c))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
3124
vCardEditor/Libs/QRCoder/PayloadGenerator.cs
Normal file
3124
vCardEditor/Libs/QRCoder/PayloadGenerator.cs
Normal file
File diff suppressed because it is too large
Load Diff
243
vCardEditor/Libs/QRCoder/PdfByteQRCode.cs
Normal file
243
vCardEditor/Libs/QRCoder/PdfByteQRCode.cs
Normal file
@@ -0,0 +1,243 @@
|
||||
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using static QRCoder.QRCodeGenerator;
|
||||
|
||||
/* This renderer is inspired by RemusVasii: https://github.com/codebude/QRCoder/issues/223 */
|
||||
namespace QRCoder
|
||||
{
|
||||
|
||||
#if NET6_0_WINDOWS
|
||||
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
|
||||
#endif
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class PdfByteQRCode : AbstractQRCode, IDisposable
|
||||
{
|
||||
private readonly byte[] pdfBinaryComment = new byte[] { 0x25, 0xe2, 0xe3, 0xcf, 0xd3 };
|
||||
|
||||
/// <summary>
|
||||
/// Constructor without params to be used in COM Objects connections
|
||||
/// </summary>
|
||||
public PdfByteQRCode() { }
|
||||
|
||||
public PdfByteQRCode(QRCodeData data) : base(data) { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a PDF document with a black & white QR code
|
||||
/// </summary>
|
||||
/// <param name="pixelsPerModule"></param>
|
||||
/// <returns></returns>
|
||||
public byte[] GetGraphic(int pixelsPerModule)
|
||||
{
|
||||
return GetGraphic(pixelsPerModule, "#000000", "#ffffff");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Takes hexadecimal color string #000000 and returns byte[]{ 0, 0, 0 }
|
||||
/// </summary>
|
||||
/// <param name="colorString">Color in HEX format like #ffffff</param>
|
||||
/// <returns></returns>
|
||||
private byte[] HexColorToByteArray(string colorString)
|
||||
{
|
||||
if (colorString.StartsWith("#"))
|
||||
colorString = colorString.Substring(1);
|
||||
byte[] byteColor = new byte[colorString.Length / 2];
|
||||
for (int i = 0; i < byteColor.Length; i++)
|
||||
byteColor[i] = byte.Parse(colorString.Substring(i * 2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
||||
return byteColor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a PDF document with given colors DPI and quality
|
||||
/// </summary>
|
||||
/// <param name="pixelsPerModule"></param>
|
||||
/// <param name="darkColorHtmlHex"></param>
|
||||
/// <param name="lightColorHtmlHex"></param>
|
||||
/// <param name="dpi"></param>
|
||||
/// <param name="jpgQuality"></param>
|
||||
/// <returns></returns>
|
||||
public byte[] GetGraphic(int pixelsPerModule, string darkColorHtmlHex, string lightColorHtmlHex, int dpi = 150, long jpgQuality = 85)
|
||||
{
|
||||
byte[] jpgArray = null, pngArray = null;
|
||||
var imgSize = QrCodeData.ModuleMatrix.Count * pixelsPerModule;
|
||||
var pdfMediaSize = (imgSize * 72 / dpi).ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
//Get QR code image
|
||||
using (var qrCode = new PngByteQRCode(QrCodeData))
|
||||
{
|
||||
pngArray = qrCode.GetGraphic(pixelsPerModule, HexColorToByteArray(darkColorHtmlHex), HexColorToByteArray(lightColorHtmlHex));
|
||||
}
|
||||
|
||||
//Create image and transofrm to JPG
|
||||
using (var msPng = new MemoryStream())
|
||||
{
|
||||
msPng.Write(pngArray, 0, pngArray.Length);
|
||||
var img = System.Drawing.Image.FromStream(msPng);
|
||||
using (var msJpeg = new MemoryStream())
|
||||
{
|
||||
// Create JPEG with specified quality
|
||||
var jpgImageCodecInfo = ImageCodecInfo.GetImageEncoders().First(x => x.MimeType == "image/jpeg");
|
||||
var jpgEncoderParameters = new EncoderParameters(1) {
|
||||
Param = new EncoderParameter[]{ new EncoderParameter(Encoder.Quality, jpgQuality) }
|
||||
};
|
||||
img.Save(msJpeg, jpgImageCodecInfo, jpgEncoderParameters);
|
||||
jpgArray = msJpeg.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
//Create PDF document
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
var writer = new StreamWriter(stream, System.Text.Encoding.GetEncoding("ASCII"));
|
||||
|
||||
var xrefs = new List<long>();
|
||||
|
||||
writer.Write("%PDF-1.5\r\n");
|
||||
writer.Flush();
|
||||
|
||||
stream.Write(pdfBinaryComment, 0, pdfBinaryComment.Length);
|
||||
writer.WriteLine();
|
||||
|
||||
writer.Flush();
|
||||
xrefs.Add(stream.Position);
|
||||
|
||||
writer.Write(
|
||||
xrefs.Count.ToString() + " 0 obj\r\n" +
|
||||
"<<\r\n" +
|
||||
"/Type /Catalog\r\n" +
|
||||
"/Pages 2 0 R\r\n" +
|
||||
">>\r\n" +
|
||||
"endobj\r\n"
|
||||
);
|
||||
|
||||
writer.Flush();
|
||||
xrefs.Add(stream.Position);
|
||||
|
||||
writer.Write(
|
||||
xrefs.Count.ToString() + " 0 obj\r\n" +
|
||||
"<<\r\n" +
|
||||
"/Count 1\r\n" +
|
||||
"/Kids [ <<\r\n" +
|
||||
"/Type /Page\r\n" +
|
||||
"/Parent 2 0 R\r\n" +
|
||||
"/MediaBox [0 0 " + pdfMediaSize + " " + pdfMediaSize + "]\r\n" +
|
||||
"/Resources << /ProcSet [ /PDF /ImageC ]\r\n" +
|
||||
"/XObject << /Im1 4 0 R >> >>\r\n" +
|
||||
"/Contents 3 0 R\r\n" +
|
||||
">> ]\r\n" +
|
||||
">>\r\n" +
|
||||
"endobj\r\n"
|
||||
);
|
||||
|
||||
var X = "q\r\n" +
|
||||
pdfMediaSize + " 0 0 " + pdfMediaSize + " 0 0 cm\r\n" +
|
||||
"/Im1 Do\r\n" +
|
||||
"Q";
|
||||
|
||||
writer.Flush();
|
||||
xrefs.Add(stream.Position);
|
||||
|
||||
writer.Write(
|
||||
xrefs.Count.ToString() + " 0 obj\r\n" +
|
||||
"<< /Length " + X.Length.ToString() + " >>\r\n" +
|
||||
"stream\r\n" +
|
||||
X + "endstream\r\n" +
|
||||
"endobj\r\n"
|
||||
);
|
||||
|
||||
writer.Flush();
|
||||
xrefs.Add(stream.Position);
|
||||
|
||||
writer.Write(
|
||||
xrefs.Count.ToString() + " 0 obj\r\n" +
|
||||
"<<\r\n" +
|
||||
"/Name /Im1\r\n" +
|
||||
"/Type /XObject\r\n" +
|
||||
"/Subtype /Image\r\n" +
|
||||
"/Width " + imgSize.ToString() + "/Height " + imgSize.ToString() + "/Length 5 0 R\r\n" +
|
||||
"/Filter /DCTDecode\r\n" +
|
||||
"/ColorSpace /DeviceRGB\r\n" +
|
||||
"/BitsPerComponent 8\r\n" +
|
||||
">>\r\n" +
|
||||
"stream\r\n"
|
||||
);
|
||||
writer.Flush();
|
||||
stream.Write(jpgArray, 0, jpgArray.Length);
|
||||
writer.Write(
|
||||
"\r\n" +
|
||||
"endstream\r\n" +
|
||||
"endobj\r\n"
|
||||
);
|
||||
|
||||
writer.Flush();
|
||||
xrefs.Add(stream.Position);
|
||||
|
||||
writer.Write(
|
||||
xrefs.Count.ToString() + " 0 obj\r\n" +
|
||||
jpgArray.Length.ToString() + " endobj\r\n"
|
||||
);
|
||||
|
||||
writer.Flush();
|
||||
var startxref = stream.Position;
|
||||
|
||||
writer.Write(
|
||||
"xref\r\n" +
|
||||
"0 " + (xrefs.Count + 1).ToString() + "\r\n" +
|
||||
"0000000000 65535 f\r\n"
|
||||
);
|
||||
|
||||
foreach (var refValue in xrefs)
|
||||
writer.Write(refValue.ToString("0000000000") + " 00000 n\r\n");
|
||||
|
||||
writer.Write(
|
||||
"trailer\r\n" +
|
||||
"<<\r\n" +
|
||||
"/Size " + (xrefs.Count + 1).ToString() + "\r\n" +
|
||||
"/Root 1 0 R\r\n" +
|
||||
">>\r\n" +
|
||||
"startxref\r\n" +
|
||||
startxref.ToString() + "\r\n" +
|
||||
"%%EOF"
|
||||
);
|
||||
|
||||
writer.Flush();
|
||||
|
||||
stream.Position = 0;
|
||||
|
||||
return stream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if NET6_0_WINDOWS
|
||||
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
|
||||
#endif
|
||||
public static class PdfByteQRCodeHelper
|
||||
{
|
||||
public static byte[] GetQRCode(string plainText, int pixelsPerModule, string darkColorHtmlHex,
|
||||
string lightColorHtmlHex, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false,
|
||||
EciMode eciMode = EciMode.Default, int requestedVersion = -1)
|
||||
{
|
||||
using (var qrGenerator = new QRCodeGenerator())
|
||||
using (
|
||||
var qrCodeData = qrGenerator.CreateQrCode(plainText, eccLevel, forceUtf8, utf8BOM, eciMode,
|
||||
requestedVersion))
|
||||
using (var qrCode = new PdfByteQRCode(qrCodeData))
|
||||
return qrCode.GetGraphic(pixelsPerModule, darkColorHtmlHex, lightColorHtmlHex);
|
||||
}
|
||||
|
||||
public static byte[] GetQRCode(string txt, ECCLevel eccLevel, int size)
|
||||
{
|
||||
using (var qrGen = new QRCodeGenerator())
|
||||
using (var qrCode = qrGen.CreateQrCode(txt, eccLevel))
|
||||
using (var qrBmp = new PdfByteQRCode(qrCode))
|
||||
return qrBmp.GetGraphic(size);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
341
vCardEditor/Libs/QRCoder/PngByteQRCode.cs
Normal file
341
vCardEditor/Libs/QRCoder/PngByteQRCode.cs
Normal file
@@ -0,0 +1,341 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using static QRCoder.QRCodeGenerator;
|
||||
|
||||
namespace QRCoder
|
||||
{
|
||||
public sealed class PngByteQRCode : AbstractQRCode, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor without params to be used in COM Objects connections
|
||||
/// </summary>
|
||||
public PngByteQRCode() { }
|
||||
|
||||
public PngByteQRCode(QRCodeData data) : base(data)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a black & white PNG of the QR code, using 1-bit grayscale.
|
||||
/// </summary>
|
||||
public byte[] GetGraphic(int pixelsPerModule, bool drawQuietZones = true)
|
||||
{
|
||||
using (var png = new PngBuilder())
|
||||
{
|
||||
var size = (this.QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : 8)) * pixelsPerModule;
|
||||
png.WriteHeader(size, size, 1, PngBuilder.ColorType.Greyscale);
|
||||
png.WriteScanlines(this.DrawScanlines(pixelsPerModule, drawQuietZones));
|
||||
png.WriteEnd();
|
||||
return png.GetBytes();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates 2-color PNG of the QR code, using 1-bit indexed color. Accepts 3-byte RGB colors for normal images and 4-byte RGBA-colors for transparent images.
|
||||
/// </summary>
|
||||
public byte[] GetGraphic(int pixelsPerModule, byte[] darkColorRgba, byte[] lightColorRgba, bool drawQuietZones = true)
|
||||
{
|
||||
using (var png = new PngBuilder())
|
||||
{
|
||||
var size = (this.QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : 8)) * pixelsPerModule;
|
||||
png.WriteHeader(size, size, 1, PngBuilder.ColorType.Indexed);
|
||||
png.WritePalette(darkColorRgba, lightColorRgba);
|
||||
png.WriteScanlines(this.DrawScanlines(pixelsPerModule, drawQuietZones));
|
||||
png.WriteEnd();
|
||||
return png.GetBytes();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a bitmap where each pixel is represented by a single bit, dark = 0 and light = 1.
|
||||
/// </summary>
|
||||
private byte[] DrawScanlines(int pixelsPerModule, bool drawQuietZones)
|
||||
{
|
||||
var moduleMatrix = this.QrCodeData.ModuleMatrix;
|
||||
var matrixSize = moduleMatrix.Count - (drawQuietZones ? 0 : 8);
|
||||
var quietZoneOffset = (drawQuietZones ? 0 : 4);
|
||||
var bytesPerScanline = (matrixSize * pixelsPerModule + 7) / 8 + 1; // A monochrome scanline is one byte for filter type then one bit per pixel.
|
||||
var scanlines = new byte[bytesPerScanline * matrixSize * pixelsPerModule];
|
||||
|
||||
for (var y = 0; y < matrixSize; y++)
|
||||
{
|
||||
var modules = moduleMatrix[y+quietZoneOffset];
|
||||
var scanlineOffset = y * pixelsPerModule * bytesPerScanline;
|
||||
|
||||
// Draw a scanline with the modules from the QR code.
|
||||
for (var x = 0; x < matrixSize; x++)
|
||||
{
|
||||
if (modules[x + quietZoneOffset])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var pixelIndex = x * pixelsPerModule;
|
||||
var endIndex = pixelIndex + pixelsPerModule;
|
||||
for (; pixelIndex < endIndex; pixelIndex++)
|
||||
{
|
||||
scanlines[scanlineOffset + 1 + pixelIndex / 8] |= (byte)(0x80 >> (pixelIndex % 8));
|
||||
}
|
||||
}
|
||||
|
||||
// Copy the scanline required number of times.
|
||||
for (var copyCount = 1; copyCount < pixelsPerModule; copyCount++)
|
||||
{
|
||||
Array.Copy(scanlines, scanlineOffset, scanlines, scanlineOffset + copyCount * bytesPerScanline, bytesPerScanline);
|
||||
}
|
||||
}
|
||||
|
||||
return scanlines;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the chunks that make up a PNG file.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://www.w3.org/TR/2003/REC-PNG-20031110 and https://www.ietf.org/rfc/rfc1950.txt.
|
||||
/// </remarks>
|
||||
private sealed class PngBuilder : IDisposable
|
||||
{
|
||||
private static readonly byte[] PngSignature = { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
|
||||
|
||||
private static readonly uint[] CrcTable = {
|
||||
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
|
||||
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
|
||||
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
|
||||
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
|
||||
};
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
// Chunk types
|
||||
private static readonly byte[] IHDR = { 73, 72, 68, 82 };
|
||||
|
||||
private static readonly byte[] IDAT = { 73, 68, 65, 84 };
|
||||
|
||||
private static readonly byte[] IEND = { 73, 69, 78, 68 };
|
||||
|
||||
private static readonly byte[] PLTE = { 80, 76, 84, 69 };
|
||||
|
||||
private static readonly byte[] tRNS = { 116, 82, 78, 83 };
|
||||
// ReSharper enable InconsistentNaming
|
||||
|
||||
public enum ColorType : byte
|
||||
{
|
||||
Greyscale = 0,
|
||||
Indexed = 3
|
||||
}
|
||||
|
||||
private MemoryStream stream = new MemoryStream();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.stream?.Dispose();
|
||||
this.stream = null;
|
||||
}
|
||||
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
var bytes = this.stream.ToArray();
|
||||
|
||||
// Enumerate chunks in file and insert their CRC32 checksums.
|
||||
var chunkOffset = PngSignature.Length;
|
||||
while (chunkOffset < bytes.Length)
|
||||
{
|
||||
// Read length field.
|
||||
var dataLength = (bytes[chunkOffset] << 24) | (bytes[chunkOffset + 1] << 16) | (bytes[chunkOffset + 2] << 8) | bytes[chunkOffset + 3];
|
||||
|
||||
// CRC is computed from type and data fields.
|
||||
var crc = Crc32(bytes, chunkOffset + 4, dataLength + 4);
|
||||
|
||||
// Write CRC to end of chunk.
|
||||
var crcOffset = chunkOffset + 8 + dataLength;
|
||||
bytes[crcOffset + 0] = (byte)(crc >> 24);
|
||||
bytes[crcOffset + 1] = (byte)(crc >> 16);
|
||||
bytes[crcOffset + 2] = (byte)(crc >> 8);
|
||||
bytes[crcOffset + 3] = (byte)crc;
|
||||
|
||||
// Seek to next chunk.
|
||||
chunkOffset = crcOffset + 4;
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the IHDR chunk. This must be the first chunk in the file.
|
||||
/// </summary>
|
||||
public void WriteHeader(int width, int height, byte bitDepth, ColorType colorType)
|
||||
{
|
||||
this.stream.Write(PngSignature, 0, PngSignature.Length);
|
||||
this.WriteChunkStart(IHDR, 13);
|
||||
|
||||
// Size.
|
||||
this.WriteIntBigEndian((uint)width);
|
||||
this.WriteIntBigEndian((uint)height);
|
||||
|
||||
// Color.
|
||||
this.stream.WriteByte(bitDepth);
|
||||
this.stream.WriteByte((byte)colorType);
|
||||
|
||||
// Constants.
|
||||
this.stream.WriteByte(0);
|
||||
this.stream.WriteByte(0);
|
||||
this.stream.WriteByte(0);
|
||||
|
||||
this.WriteChunkEnd();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the PLTE chunk, and also the tRNS chunk if necessary. Must come before the IDAT chunk.
|
||||
/// </summary>
|
||||
public void WritePalette(params byte[][] rgbaColors)
|
||||
{
|
||||
const int Red = 0, Green = 1, Blue = 2, Alpha = 3;
|
||||
const byte Opaque = 255;
|
||||
var hasAlpha = false;
|
||||
|
||||
this.WriteChunkStart(PLTE, 3 * rgbaColors.Length);
|
||||
foreach (var color in rgbaColors)
|
||||
{
|
||||
hasAlpha |= color.Length > Alpha && color[Alpha] < Opaque;
|
||||
this.stream.WriteByte(color[Red]);
|
||||
this.stream.WriteByte(color[Green]);
|
||||
this.stream.WriteByte(color[Blue]);
|
||||
}
|
||||
this.WriteChunkEnd();
|
||||
|
||||
if (!hasAlpha)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.WriteChunkStart(tRNS, rgbaColors.Length);
|
||||
foreach (var color in rgbaColors)
|
||||
{
|
||||
this.stream.WriteByte(color.Length > Alpha ? color[Alpha] : Opaque);
|
||||
}
|
||||
this.WriteChunkEnd();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the IDAT chunk with the actual picture.
|
||||
/// </summary>
|
||||
public void WriteScanlines(byte[] scanlines)
|
||||
{
|
||||
using (var idatStream = new MemoryStream())
|
||||
{
|
||||
Deflate(idatStream, scanlines);
|
||||
|
||||
this.WriteChunkStart(IDAT, (int)(idatStream.Length + 6));
|
||||
|
||||
// Deflate header.
|
||||
this.stream.WriteByte(0x78); // 8 Deflate algorithm, 7 max window size
|
||||
this.stream.WriteByte(0x9C); // Check bits.
|
||||
|
||||
// Compressed data.
|
||||
idatStream.Position = 0;
|
||||
#if NET35
|
||||
idatStream.WriteTo(this.stream);
|
||||
#else
|
||||
idatStream.CopyTo(this.stream);
|
||||
#endif
|
||||
// Deflate checksum.
|
||||
var adler = Adler32(scanlines, 0, scanlines.Length);
|
||||
this.WriteIntBigEndian(adler);
|
||||
|
||||
this.WriteChunkEnd();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the IEND chunk. This must be the last chunk in the file.
|
||||
/// </summary>
|
||||
public void WriteEnd()
|
||||
{
|
||||
this.WriteChunkStart(IEND, 0);
|
||||
this.WriteChunkEnd();
|
||||
}
|
||||
|
||||
private void WriteChunkStart(byte[] type, int length)
|
||||
{
|
||||
this.WriteIntBigEndian((uint)length);
|
||||
this.stream.Write(type, 0, 4);
|
||||
}
|
||||
|
||||
private void WriteChunkEnd()
|
||||
{
|
||||
// Reserves 4 bytes space for crc32 so GetBytes can add it later.
|
||||
this.stream.SetLength(this.stream.Length + 4);
|
||||
this.stream.Position += 4;
|
||||
}
|
||||
|
||||
private void WriteIntBigEndian(uint value)
|
||||
{
|
||||
this.stream.WriteByte((byte)(value >> 24));
|
||||
this.stream.WriteByte((byte)(value >> 16));
|
||||
this.stream.WriteByte((byte)(value >> 8));
|
||||
this.stream.WriteByte((byte)value);
|
||||
}
|
||||
|
||||
private static void Deflate(Stream output, byte[] bytes)
|
||||
{
|
||||
using (var deflateStream = new DeflateStream(output, CompressionMode.Compress, leaveOpen: true))
|
||||
{
|
||||
deflateStream.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
}
|
||||
|
||||
// Reference implementation from RFC 1950. Not optimized.
|
||||
private static uint Adler32(byte[] data, int index, int length)
|
||||
{
|
||||
const uint Base = 65521;
|
||||
uint s1 = 1, s2 = 0;
|
||||
|
||||
var end = index + length;
|
||||
for (var n = index; n < end; n++)
|
||||
{
|
||||
s1 = (s1 + data[n]) % Base;
|
||||
s2 = (s2 + s1) % Base;
|
||||
}
|
||||
|
||||
return (s2 << 16) + s1;
|
||||
}
|
||||
|
||||
// Reference implementation from REC-PNG-20031110. Not optimized.
|
||||
private static uint Crc32(byte[] data, int index, int length)
|
||||
{
|
||||
var c = 0xffffffff;
|
||||
|
||||
var end = index + length;
|
||||
for (var n = index; n < end; n++)
|
||||
{
|
||||
c = CrcTable[(c ^ data[n]) & 0xff] ^ (c >> 8);
|
||||
}
|
||||
|
||||
return c ^ 0xffffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class PngByteQRCodeHelper
|
||||
{
|
||||
public static byte[] GetQRCode(string plainText, int pixelsPerModule, byte[] darkColorRgba, byte[] lightColorRgba, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, bool drawQuietZones = true)
|
||||
{
|
||||
using (var qrGenerator = new QRCodeGenerator())
|
||||
using (var qrCodeData = qrGenerator.CreateQrCode(plainText, eccLevel, forceUtf8, utf8BOM, eciMode, requestedVersion))
|
||||
using (var qrCode = new PngByteQRCode(qrCodeData))
|
||||
return qrCode.GetGraphic(pixelsPerModule, darkColorRgba, lightColorRgba, drawQuietZones);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static byte[] GetQRCode(string txt, QRCodeGenerator.ECCLevel eccLevel, int size, bool drawQuietZones = true)
|
||||
{
|
||||
using (var qrGen = new QRCodeGenerator())
|
||||
using (var qrCode = qrGen.CreateQrCode(txt, eccLevel))
|
||||
using (var qrPng = new PngByteQRCode(qrCode))
|
||||
return qrPng.GetGraphic(size, drawQuietZones);
|
||||
}
|
||||
}
|
||||
}
|
||||
161
vCardEditor/Libs/QRCoder/PostscriptQRCode.cs
Normal file
161
vCardEditor/Libs/QRCoder/PostscriptQRCode.cs
Normal file
@@ -0,0 +1,161 @@
|
||||
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using static QRCoder.QRCodeGenerator;
|
||||
|
||||
namespace QRCoder
|
||||
{
|
||||
|
||||
#if NET6_0_WINDOWS
|
||||
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
|
||||
#endif
|
||||
public class PostscriptQRCode : AbstractQRCode, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor without params to be used in COM Objects connections
|
||||
/// </summary>
|
||||
public PostscriptQRCode() { }
|
||||
public PostscriptQRCode(QRCodeData data) : base(data) { }
|
||||
|
||||
public string GetGraphic(int pointsPerModule, bool epsFormat = false)
|
||||
{
|
||||
var viewBox = new Size(pointsPerModule * this.QrCodeData.ModuleMatrix.Count, pointsPerModule * this.QrCodeData.ModuleMatrix.Count);
|
||||
return this.GetGraphic(viewBox, Color.Black, Color.White, true, epsFormat);
|
||||
}
|
||||
public string GetGraphic(int pointsPerModule, Color darkColor, Color lightColor, bool drawQuietZones = true, bool epsFormat = false)
|
||||
{
|
||||
var viewBox = new Size(pointsPerModule * this.QrCodeData.ModuleMatrix.Count, pointsPerModule * this.QrCodeData.ModuleMatrix.Count);
|
||||
return this.GetGraphic(viewBox, darkColor, lightColor, drawQuietZones, epsFormat);
|
||||
}
|
||||
|
||||
public string GetGraphic(int pointsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false)
|
||||
{
|
||||
var viewBox = new Size(pointsPerModule * this.QrCodeData.ModuleMatrix.Count, pointsPerModule * this.QrCodeData.ModuleMatrix.Count);
|
||||
return this.GetGraphic(viewBox, darkColorHex, lightColorHex, drawQuietZones, epsFormat);
|
||||
}
|
||||
|
||||
public string GetGraphic(Size viewBox, bool drawQuietZones = true, bool epsFormat = false)
|
||||
{
|
||||
return this.GetGraphic(viewBox, Color.Black, Color.White, drawQuietZones, epsFormat);
|
||||
}
|
||||
|
||||
public string GetGraphic(Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false)
|
||||
{
|
||||
return this.GetGraphic(viewBox, ColorTranslator.FromHtml(darkColorHex), ColorTranslator.FromHtml(lightColorHex), drawQuietZones, epsFormat);
|
||||
}
|
||||
|
||||
public string GetGraphic(Size viewBox, Color darkColor, Color lightColor, bool drawQuietZones = true, bool epsFormat = false)
|
||||
{
|
||||
var offset = drawQuietZones ? 0 : 4;
|
||||
var drawableModulesCount = this.QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : offset * 2);
|
||||
var pointsPerModule = (double)Math.Min(viewBox.Width, viewBox.Height) / (double)drawableModulesCount;
|
||||
|
||||
string psFile = string.Format(psHeader, new object[] {
|
||||
DateTime.Now.ToString("s"), CleanSvgVal(viewBox.Width), CleanSvgVal(pointsPerModule),
|
||||
epsFormat ? "EPSF-3.0" : string.Empty
|
||||
});
|
||||
psFile += string.Format(psFunctions, new object[] {
|
||||
CleanSvgVal(darkColor.R /255.0), CleanSvgVal(darkColor.G /255.0), CleanSvgVal(darkColor.B /255.0),
|
||||
CleanSvgVal(lightColor.R /255.0), CleanSvgVal(lightColor.G /255.0), CleanSvgVal(lightColor.B /255.0),
|
||||
drawableModulesCount
|
||||
});
|
||||
|
||||
for (int xi = offset; xi < offset + drawableModulesCount; xi++)
|
||||
{
|
||||
if (xi > offset)
|
||||
psFile += "nl\n";
|
||||
for (int yi = offset; yi < offset + drawableModulesCount; yi++)
|
||||
{
|
||||
psFile += (this.QrCodeData.ModuleMatrix[xi][yi] ? "f " : "b ");
|
||||
}
|
||||
psFile += "\n";
|
||||
}
|
||||
return psFile + psFooter;
|
||||
}
|
||||
|
||||
private string CleanSvgVal(double input)
|
||||
{
|
||||
//Clean double values for international use/formats
|
||||
return input.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
private const string psHeader = @"%!PS-Adobe-3.0 {3}
|
||||
%%Creator: QRCoder.NET
|
||||
%%Title: QRCode
|
||||
%%CreationDate: {0}
|
||||
%%DocumentData: Clean7Bit
|
||||
%%Origin: 0
|
||||
%%DocumentMedia: Default {1} {1} 0 () ()
|
||||
%%BoundingBox: 0 0 {1} {1}
|
||||
%%LanguageLevel: 2
|
||||
%%Pages: 1
|
||||
%%Page: 1 1
|
||||
%%EndComments
|
||||
%%BeginConstants
|
||||
/sz {1} def
|
||||
/sc {2} def
|
||||
%%EndConstants
|
||||
%%BeginFeature: *PageSize Default
|
||||
<< /PageSize [ sz sz ] /ImagingBBox null >> setpagedevice
|
||||
%%EndFeature
|
||||
";
|
||||
|
||||
private const string psFunctions = @"%%BeginFunctions
|
||||
/csquare {{
|
||||
newpath
|
||||
0 0 moveto
|
||||
0 1 rlineto
|
||||
1 0 rlineto
|
||||
0 -1 rlineto
|
||||
closepath
|
||||
setrgbcolor
|
||||
fill
|
||||
}} def
|
||||
/f {{
|
||||
{0} {1} {2} csquare
|
||||
1 0 translate
|
||||
}} def
|
||||
/b {{
|
||||
1 0 translate
|
||||
}} def
|
||||
/background {{
|
||||
{3} {4} {5} csquare
|
||||
}} def
|
||||
/nl {{
|
||||
-{6} -1 translate
|
||||
}} def
|
||||
%%EndFunctions
|
||||
%%BeginBody
|
||||
0 0 moveto
|
||||
gsave
|
||||
sz sz scale
|
||||
background
|
||||
grestore
|
||||
gsave
|
||||
sc sc scale
|
||||
0 {6} 1 sub translate
|
||||
";
|
||||
|
||||
private const string psFooter = @"%%EndBody
|
||||
grestore
|
||||
showpage
|
||||
%%EOF
|
||||
";
|
||||
}
|
||||
|
||||
#if NET6_0_WINDOWS
|
||||
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
|
||||
#endif
|
||||
public static class PostscriptQRCodeHelper
|
||||
{
|
||||
public static string GetQRCode(string plainText, int pointsPerModule, string darkColorHex, string lightColorHex, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false)
|
||||
{
|
||||
using (var qrGenerator = new QRCodeGenerator())
|
||||
using (var qrCodeData = qrGenerator.CreateQrCode(plainText, eccLevel, forceUtf8, utf8BOM, eciMode, requestedVersion))
|
||||
using (var qrCode = new PostscriptQRCode(qrCodeData))
|
||||
return qrCode.GetGraphic(pointsPerModule, darkColorHex, lightColorHex, drawQuietZones, epsFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
138
vCardEditor/Libs/QRCoder/QRCode.cs
Normal file
138
vCardEditor/Libs/QRCoder/QRCode.cs
Normal file
@@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using static QRCoder.QRCodeGenerator;
|
||||
|
||||
namespace QRCoder
|
||||
{
|
||||
public class QRCode : AbstractQRCode, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor without params to be used in COM Objects connections
|
||||
/// </summary>
|
||||
public QRCode() { }
|
||||
|
||||
public QRCode(QRCodeData data) : base(data) {}
|
||||
|
||||
public Bitmap GetGraphic(int pixelsPerModule)
|
||||
{
|
||||
return this.GetGraphic(pixelsPerModule, Color.Black, Color.White, true);
|
||||
}
|
||||
|
||||
public Bitmap GetGraphic(int pixelsPerModule, string darkColorHtmlHex, string lightColorHtmlHex, bool drawQuietZones = true)
|
||||
{
|
||||
return this.GetGraphic(pixelsPerModule, ColorTranslator.FromHtml(darkColorHtmlHex), ColorTranslator.FromHtml(lightColorHtmlHex), drawQuietZones);
|
||||
}
|
||||
|
||||
public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, bool drawQuietZones = true)
|
||||
{
|
||||
var size = (this.QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : 8)) * pixelsPerModule;
|
||||
var offset = drawQuietZones ? 0 : 4 * pixelsPerModule;
|
||||
|
||||
var bmp = new Bitmap(size, size);
|
||||
using (var gfx = Graphics.FromImage(bmp))
|
||||
using (var lightBrush = new SolidBrush(lightColor))
|
||||
using (var darkBrush = new SolidBrush(darkColor))
|
||||
{
|
||||
for (var x = 0; x < size + offset; x = x + pixelsPerModule)
|
||||
{
|
||||
for (var y = 0; y < size + offset; y = y + pixelsPerModule)
|
||||
{
|
||||
var module = this.QrCodeData.ModuleMatrix[(y + pixelsPerModule) / pixelsPerModule - 1][(x + pixelsPerModule) / pixelsPerModule - 1];
|
||||
|
||||
if (module)
|
||||
{
|
||||
gfx.FillRectangle(darkBrush, new Rectangle(x - offset, y - offset, pixelsPerModule, pixelsPerModule));
|
||||
}
|
||||
else
|
||||
{
|
||||
gfx.FillRectangle(lightBrush, new Rectangle(x - offset, y - offset, pixelsPerModule, pixelsPerModule));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gfx.Save();
|
||||
}
|
||||
|
||||
return bmp;
|
||||
}
|
||||
|
||||
public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, Bitmap icon=null, int iconSizePercent=15, int iconBorderWidth = 0, bool drawQuietZones = true, Color? iconBackgroundColor = null)
|
||||
{
|
||||
var size = (this.QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : 8)) * pixelsPerModule;
|
||||
var offset = drawQuietZones ? 0 : 4 * pixelsPerModule;
|
||||
|
||||
var bmp = new Bitmap(size, size, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||
|
||||
using (var gfx = Graphics.FromImage(bmp))
|
||||
using (var lightBrush = new SolidBrush(lightColor))
|
||||
using (var darkBrush = new SolidBrush(darkColor))
|
||||
{
|
||||
gfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
gfx.CompositingQuality = CompositingQuality.HighQuality;
|
||||
gfx.Clear(lightColor);
|
||||
var drawIconFlag = icon != null && iconSizePercent > 0 && iconSizePercent <= 100;
|
||||
|
||||
for (var x = 0; x < size + offset; x = x + pixelsPerModule)
|
||||
{
|
||||
for (var y = 0; y < size + offset; y = y + pixelsPerModule)
|
||||
{
|
||||
var moduleBrush = this.QrCodeData.ModuleMatrix[(y + pixelsPerModule) / pixelsPerModule - 1][(x + pixelsPerModule) / pixelsPerModule - 1] ? darkBrush : lightBrush;
|
||||
gfx.FillRectangle(moduleBrush , new Rectangle(x - offset, y - offset, pixelsPerModule, pixelsPerModule));
|
||||
}
|
||||
}
|
||||
|
||||
if (drawIconFlag)
|
||||
{
|
||||
float iconDestWidth = iconSizePercent * bmp.Width / 100f;
|
||||
float iconDestHeight = drawIconFlag ? iconDestWidth * icon.Height / icon.Width : 0;
|
||||
float iconX = (bmp.Width - iconDestWidth) / 2;
|
||||
float iconY = (bmp.Height - iconDestHeight) / 2;
|
||||
var centerDest = new RectangleF(iconX - iconBorderWidth, iconY - iconBorderWidth, iconDestWidth + iconBorderWidth * 2, iconDestHeight + iconBorderWidth * 2);
|
||||
var iconDestRect = new RectangleF(iconX, iconY, iconDestWidth, iconDestHeight);
|
||||
var iconBgBrush = iconBackgroundColor != null ? new SolidBrush((Color)iconBackgroundColor) : lightBrush;
|
||||
//Only render icon/logo background, if iconBorderWith is set > 0
|
||||
if (iconBorderWidth > 0)
|
||||
{
|
||||
using (GraphicsPath iconPath = CreateRoundedRectanglePath(centerDest, iconBorderWidth * 2))
|
||||
{
|
||||
gfx.FillPath(iconBgBrush, iconPath);
|
||||
}
|
||||
}
|
||||
gfx.DrawImage(icon, iconDestRect, new RectangleF(0, 0, icon.Width, icon.Height), GraphicsUnit.Pixel);
|
||||
}
|
||||
|
||||
gfx.Save();
|
||||
}
|
||||
|
||||
return bmp;
|
||||
}
|
||||
|
||||
internal GraphicsPath CreateRoundedRectanglePath(RectangleF rect, int cornerRadius)
|
||||
{
|
||||
var roundedRect = new GraphicsPath();
|
||||
roundedRect.AddArc(rect.X, rect.Y, cornerRadius * 2, cornerRadius * 2, 180, 90);
|
||||
roundedRect.AddLine(rect.X + cornerRadius, rect.Y, rect.Right - cornerRadius * 2, rect.Y);
|
||||
roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y, cornerRadius * 2, cornerRadius * 2, 270, 90);
|
||||
roundedRect.AddLine(rect.Right, rect.Y + cornerRadius * 2, rect.Right, rect.Y + rect.Height - cornerRadius * 2);
|
||||
roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y + rect.Height - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 0, 90);
|
||||
roundedRect.AddLine(rect.Right - cornerRadius * 2, rect.Bottom, rect.X + cornerRadius * 2, rect.Bottom);
|
||||
roundedRect.AddArc(rect.X, rect.Bottom - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 90, 90);
|
||||
roundedRect.AddLine(rect.X, rect.Bottom - cornerRadius * 2, rect.X, rect.Y + cornerRadius * 2);
|
||||
roundedRect.CloseFigure();
|
||||
return roundedRect;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class QRCodeHelper
|
||||
{
|
||||
public static Bitmap GetQRCode(string plainText, int pixelsPerModule, Color darkColor, Color lightColor, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, Bitmap icon = null, int iconSizePercent = 15, int iconBorderWidth = 0, bool drawQuietZones = true)
|
||||
{
|
||||
using (var qrGenerator = new QRCodeGenerator())
|
||||
using (var qrCodeData = qrGenerator.CreateQrCode(plainText, eccLevel, forceUtf8, utf8BOM, eciMode, requestedVersion))
|
||||
using (var qrCode = new QRCode(qrCodeData))
|
||||
return qrCode.GetGraphic(pixelsPerModule, darkColor, lightColor, icon, iconSizePercent, iconBorderWidth, drawQuietZones);
|
||||
}
|
||||
}
|
||||
}
|
||||
185
vCardEditor/Libs/QRCoder/QRCodeData.cs
Normal file
185
vCardEditor/Libs/QRCoder/QRCodeData.cs
Normal file
@@ -0,0 +1,185 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace QRCoder
|
||||
{
|
||||
using QRCoder.Framework4._0Methods;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
|
||||
public class QRCodeData : IDisposable
|
||||
{
|
||||
public List<BitArray> ModuleMatrix { get; set; }
|
||||
|
||||
public QRCodeData(int version)
|
||||
{
|
||||
this.Version = version;
|
||||
var size = ModulesPerSideFromVersion(version);
|
||||
this.ModuleMatrix = new List<BitArray>();
|
||||
for (var i = 0; i < size; i++)
|
||||
this.ModuleMatrix.Add(new BitArray(size));
|
||||
}
|
||||
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
|
||||
public QRCodeData(string pathToRawData, Compression compressMode) : this(File.ReadAllBytes(pathToRawData), compressMode)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
public QRCodeData(byte[] rawData, Compression compressMode)
|
||||
{
|
||||
var bytes = new List<byte>(rawData);
|
||||
|
||||
//Decompress
|
||||
if (compressMode == Compression.Deflate)
|
||||
{
|
||||
using (var input = new MemoryStream(bytes.ToArray()))
|
||||
{
|
||||
using (var output = new MemoryStream())
|
||||
{
|
||||
using (var dstream = new DeflateStream(input, CompressionMode.Decompress))
|
||||
{
|
||||
Stream4Methods.CopyTo(dstream, output);
|
||||
}
|
||||
bytes = new List<byte>(output.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (compressMode == Compression.GZip)
|
||||
{
|
||||
using (var input = new MemoryStream(bytes.ToArray()))
|
||||
{
|
||||
using (var output = new MemoryStream())
|
||||
{
|
||||
using (var dstream = new GZipStream(input, CompressionMode.Decompress))
|
||||
{
|
||||
Stream4Methods.CopyTo(dstream, output);
|
||||
}
|
||||
bytes = new List<byte>(output.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bytes[0] != 0x51 || bytes[1] != 0x52 || bytes[2] != 0x52)
|
||||
throw new Exception("Invalid raw data file. Filetype doesn't match \"QRR\".");
|
||||
|
||||
//Set QR code version
|
||||
var sideLen = (int)bytes[4];
|
||||
bytes.RemoveRange(0, 5);
|
||||
this.Version = (sideLen - 21 - 8) / 4 + 1;
|
||||
|
||||
//Unpack
|
||||
var modules = new Queue<bool>(8 * bytes.Count);
|
||||
foreach (var b in bytes)
|
||||
{
|
||||
var bArr = new BitArray(new byte[] { b });
|
||||
for (int i = 7; i >= 0; i--)
|
||||
{
|
||||
modules.Enqueue((b & (1 << i)) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
//Build module matrix
|
||||
this.ModuleMatrix = new List<BitArray>(sideLen);
|
||||
for (int y = 0; y < sideLen; y++)
|
||||
{
|
||||
this.ModuleMatrix.Add(new BitArray(sideLen));
|
||||
for (int x = 0; x < sideLen; x++)
|
||||
{
|
||||
this.ModuleMatrix[y][x] = modules.Dequeue();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public byte[] GetRawData(Compression compressMode)
|
||||
{
|
||||
var bytes = new List<byte>();
|
||||
|
||||
//Add header - signature ("QRR")
|
||||
bytes.AddRange(new byte[]{ 0x51, 0x52, 0x52, 0x00 });
|
||||
|
||||
//Add header - rowsize
|
||||
bytes.Add((byte)ModuleMatrix.Count);
|
||||
|
||||
//Build data queue
|
||||
var dataQueue = new Queue<int>();
|
||||
foreach (var row in ModuleMatrix)
|
||||
{
|
||||
foreach (var module in row)
|
||||
{
|
||||
dataQueue.Enqueue((bool)module ? 1 : 0);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 8 - (ModuleMatrix.Count * ModuleMatrix.Count) % 8; i++)
|
||||
{
|
||||
dataQueue.Enqueue(0);
|
||||
}
|
||||
|
||||
//Process queue
|
||||
while (dataQueue.Count > 0)
|
||||
{
|
||||
byte b = 0;
|
||||
for (int i = 7; i >= 0; i--)
|
||||
{
|
||||
b += (byte)(dataQueue.Dequeue() << i);
|
||||
}
|
||||
bytes.Add(b);
|
||||
}
|
||||
var rawData = bytes.ToArray();
|
||||
|
||||
//Compress stream (optional)
|
||||
if (compressMode == Compression.Deflate)
|
||||
{
|
||||
using (var output = new MemoryStream())
|
||||
{
|
||||
using (var dstream = new DeflateStream(output, CompressionMode.Compress))
|
||||
{
|
||||
dstream.Write(rawData, 0, rawData.Length);
|
||||
}
|
||||
rawData = output.ToArray();
|
||||
}
|
||||
}
|
||||
else if (compressMode == Compression.GZip)
|
||||
{
|
||||
using (var output = new MemoryStream())
|
||||
{
|
||||
using (GZipStream gzipStream = new GZipStream(output, CompressionMode.Compress, true))
|
||||
{
|
||||
gzipStream.Write(rawData, 0, rawData.Length);
|
||||
}
|
||||
rawData = output.ToArray();
|
||||
}
|
||||
}
|
||||
return rawData;
|
||||
}
|
||||
|
||||
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0
|
||||
public void SaveRawData(string filePath, Compression compressMode)
|
||||
{
|
||||
File.WriteAllBytes(filePath, GetRawData(compressMode));
|
||||
}
|
||||
#endif
|
||||
|
||||
public int Version { get; private set; }
|
||||
|
||||
private static int ModulesPerSideFromVersion(int version)
|
||||
{
|
||||
return 21 + (version - 1) * 4;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.ModuleMatrix = null;
|
||||
this.Version = 0;
|
||||
|
||||
}
|
||||
|
||||
public enum Compression
|
||||
{
|
||||
Uncompressed,
|
||||
Deflate,
|
||||
GZip
|
||||
}
|
||||
}
|
||||
}
|
||||
1596
vCardEditor/Libs/QRCoder/QRCodeGenerator.cs
Normal file
1596
vCardEditor/Libs/QRCoder/QRCodeGenerator.cs
Normal file
File diff suppressed because it is too large
Load Diff
391
vCardEditor/Libs/QRCoder/SvgQRCode.cs
Normal file
391
vCardEditor/Libs/QRCoder/SvgQRCode.cs
Normal file
@@ -0,0 +1,391 @@
|
||||
using QRCoder.Extensions;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using static QRCoder.QRCodeGenerator;
|
||||
using static QRCoder.SvgQRCode;
|
||||
|
||||
namespace QRCoder
|
||||
{
|
||||
|
||||
public class SvgQRCode : AbstractQRCode, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor without params to be used in COM Objects connections
|
||||
/// </summary>
|
||||
public SvgQRCode() { }
|
||||
public SvgQRCode(QRCodeData data) : base(data) { }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a QR code as SVG string
|
||||
/// </summary>
|
||||
/// <param name="pixelsPerModule">The pixel size each b/w module is drawn</param>
|
||||
/// <returns>SVG as string</returns>
|
||||
public string GetGraphic(int pixelsPerModule)
|
||||
{
|
||||
var viewBox = new Size(pixelsPerModule*this.QrCodeData.ModuleMatrix.Count, pixelsPerModule * this.QrCodeData.ModuleMatrix.Count);
|
||||
return this.GetGraphic(viewBox, Color.Black, Color.White);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a QR code as SVG string with custom colors, optional quietzone and logo
|
||||
/// </summary>
|
||||
/// <param name="pixelsPerModule">The pixel size each b/w module is drawn</param>
|
||||
/// <param name="darkColor">Color of the dark modules</param>
|
||||
/// <param name="lightColor">Color of the light modules</param>
|
||||
/// <param name="drawQuietZones">If true a white border is drawn around the whole QR Code</param>
|
||||
/// <param name="sizingMode">Defines if width/height or viewbox should be used for size definition</param>
|
||||
/// <param name="logo">A (optional) logo to be rendered on the code (either Bitmap or SVG)</param>
|
||||
/// <returns>SVG as string</returns>
|
||||
public string GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo logo = null)
|
||||
{
|
||||
var offset = drawQuietZones ? 0 : 4;
|
||||
var edgeSize = this.QrCodeData.ModuleMatrix.Count * pixelsPerModule - (offset * 2 * pixelsPerModule);
|
||||
var viewBox = new Size(edgeSize, edgeSize);
|
||||
return this.GetGraphic(viewBox, darkColor, lightColor, drawQuietZones, sizingMode, logo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a QR code as SVG string with custom colors (in HEX syntax), optional quietzone and logo
|
||||
/// </summary>
|
||||
/// <param name="pixelsPerModule">The pixel size each b/w module is drawn</param>
|
||||
/// <param name="darkColorHex">The color of the dark/black modules in hex (e.g. #000000) representation</param>
|
||||
/// <param name="lightColorHex">The color of the light/white modules in hex (e.g. #ffffff) representation</param>
|
||||
/// <param name="drawQuietZones">If true a white border is drawn around the whole QR Code</param>
|
||||
/// <param name="sizingMode">Defines if width/height or viewbox should be used for size definition</param>
|
||||
/// <param name="logo">A (optional) logo to be rendered on the code (either Bitmap or SVG)</param>
|
||||
/// <returns>SVG as string</returns>
|
||||
public string GetGraphic(int pixelsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo logo = null)
|
||||
{
|
||||
var offset = drawQuietZones ? 0 : 4;
|
||||
var edgeSize = this.QrCodeData.ModuleMatrix.Count * pixelsPerModule - (offset * 2 * pixelsPerModule);
|
||||
var viewBox = new Size(edgeSize, edgeSize);
|
||||
return this.GetGraphic(viewBox, darkColorHex, lightColorHex, drawQuietZones, sizingMode, logo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a QR code as SVG string with optional quietzone and logo
|
||||
/// </summary>
|
||||
/// <param name="viewBox">The viewbox of the QR code graphic</param>
|
||||
/// <param name="drawQuietZones">If true a white border is drawn around the whole QR Code</param>
|
||||
/// <param name="sizingMode">Defines if width/height or viewbox should be used for size definition</param>
|
||||
/// <param name="logo">A (optional) logo to be rendered on the code (either Bitmap or SVG)</param>
|
||||
/// <returns>SVG as string</returns>
|
||||
public string GetGraphic(Size viewBox, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo logo = null)
|
||||
{
|
||||
return this.GetGraphic(viewBox, Color.Black, Color.White, drawQuietZones, sizingMode, logo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a QR code as SVG string with custom colors and optional quietzone and logo
|
||||
/// </summary>
|
||||
/// <param name="viewBox">The viewbox of the QR code graphic</param>
|
||||
/// <param name="darkColor">Color of the dark modules</param>
|
||||
/// <param name="lightColor">Color of the light modules</param>
|
||||
/// <param name="drawQuietZones">If true a white border is drawn around the whole QR Code</param>
|
||||
/// <param name="sizingMode">Defines if width/height or viewbox should be used for size definition</param>
|
||||
/// <param name="logo">A (optional) logo to be rendered on the code (either Bitmap or SVG)</param>
|
||||
/// <returns>SVG as string</returns>
|
||||
public string GetGraphic(Size viewBox, Color darkColor, Color lightColor, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo logo = null)
|
||||
{
|
||||
return this.GetGraphic(viewBox, ColorTranslator.ToHtml(Color.FromArgb(darkColor.ToArgb())), ColorTranslator.ToHtml(Color.FromArgb(lightColor.ToArgb())), drawQuietZones, sizingMode, logo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a QR code as SVG string with custom colors (in HEX syntax), optional quietzone and logo
|
||||
/// </summary>
|
||||
/// <param name="viewBox">The viewbox of the QR code graphic</param>
|
||||
/// <param name="darkColorHex">The color of the dark/black modules in hex (e.g. #000000) representation</param>
|
||||
/// <param name="lightColorHex">The color of the light/white modules in hex (e.g. #ffffff) representation</param>
|
||||
/// <param name="drawQuietZones">If true a white border is drawn around the whole QR Code</param>
|
||||
/// <param name="sizingMode">Defines if width/height or viewbox should be used for size definition</param>
|
||||
/// <param name="logo">A (optional) logo to be rendered on the code (either Bitmap or SVG)</param>
|
||||
/// <returns>SVG as string</returns>
|
||||
public string GetGraphic(Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo logo = null)
|
||||
{
|
||||
int offset = drawQuietZones ? 0 : 4;
|
||||
int drawableModulesCount = this.QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : offset * 2);
|
||||
double pixelsPerModule = Math.Min(viewBox.Width, viewBox.Height) / (double)drawableModulesCount;
|
||||
double qrSize = drawableModulesCount * pixelsPerModule;
|
||||
string svgSizeAttributes = (sizingMode == SizingMode.WidthHeightAttribute) ? $@"width=""{viewBox.Width}"" height=""{viewBox.Height}""" : $@"viewBox=""0 0 {viewBox.Width} {viewBox.Height}""";
|
||||
ImageAttributes? logoAttr = null;
|
||||
if (logo != null)
|
||||
logoAttr = GetLogoAttributes(logo, viewBox);
|
||||
|
||||
// Merge horizontal rectangles
|
||||
int[,] matrix = new int[drawableModulesCount, drawableModulesCount];
|
||||
for (int yi = 0; yi < drawableModulesCount; yi += 1)
|
||||
{
|
||||
BitArray bitArray = this.QrCodeData.ModuleMatrix[yi+offset];
|
||||
|
||||
int x0 = -1;
|
||||
int xL = 0;
|
||||
for (int xi = 0; xi < drawableModulesCount; xi += 1)
|
||||
{
|
||||
matrix[yi, xi] = 0;
|
||||
if (bitArray[xi+offset] && (logo == null || !logo.FillLogoBackground() || !IsBlockedByLogo((xi+offset)*pixelsPerModule, (yi+offset) * pixelsPerModule, logoAttr, pixelsPerModule)))
|
||||
{
|
||||
if(x0 == -1)
|
||||
{
|
||||
x0 = xi;
|
||||
}
|
||||
xL += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(xL > 0)
|
||||
{
|
||||
matrix[yi, x0] = xL;
|
||||
x0 = -1;
|
||||
xL = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (xL > 0)
|
||||
{
|
||||
matrix[yi, x0] = xL;
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder svgFile = new StringBuilder($@"<svg version=""1.1"" baseProfile=""full"" shape-rendering=""crispEdges"" {svgSizeAttributes} xmlns=""http://www.w3.org/2000/svg"" xmlns:xlink=""http://www.w3.org/1999/xlink"">");
|
||||
svgFile.AppendLine($@"<rect x=""0"" y=""0"" width=""{CleanSvgVal(qrSize)}"" height=""{CleanSvgVal(qrSize)}"" fill=""{lightColorHex}"" />");
|
||||
for (int yi = 0; yi < drawableModulesCount; yi += 1)
|
||||
{
|
||||
double y = yi * pixelsPerModule;
|
||||
for (int xi = 0; xi < drawableModulesCount; xi += 1)
|
||||
{
|
||||
int xL = matrix[yi, xi];
|
||||
if(xL > 0)
|
||||
{
|
||||
// Merge vertical rectangles
|
||||
int yL = 1;
|
||||
for (int y2 = yi + 1; y2 < drawableModulesCount; y2 += 1)
|
||||
{
|
||||
if(matrix[y2, xi] == xL)
|
||||
{
|
||||
matrix[y2, xi] = 0;
|
||||
yL += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Output SVG rectangles
|
||||
double x = xi * pixelsPerModule;
|
||||
if (logo == null || !logo.FillLogoBackground() || !IsBlockedByLogo(x, y, logoAttr, pixelsPerModule))
|
||||
svgFile.AppendLine($@"<rect x=""{CleanSvgVal(x)}"" y=""{CleanSvgVal(y)}"" width=""{CleanSvgVal(xL * pixelsPerModule)}"" height=""{CleanSvgVal(yL * pixelsPerModule)}"" fill=""{darkColorHex}"" />");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Render logo, if set
|
||||
if (logo != null)
|
||||
{
|
||||
if (!logo.IsEmbedded())
|
||||
{
|
||||
svgFile.AppendLine($@"<svg width=""100%"" height=""100%"" version=""1.1"" xmlns = ""http://www.w3.org/2000/svg"">");
|
||||
svgFile.AppendLine($@"<image x=""{CleanSvgVal(logoAttr.Value.X)}"" y=""{CleanSvgVal(logoAttr.Value.Y)}"" width=""{CleanSvgVal(logoAttr.Value.Width)}"" height=""{CleanSvgVal(logoAttr.Value.Height)}"" xlink:href=""{logo.GetDataUri()}"" />");
|
||||
svgFile.AppendLine(@"</svg>");
|
||||
}
|
||||
else
|
||||
{
|
||||
var rawLogo = (string)logo.GetRawLogo();
|
||||
var svg = System.Xml.Linq.XDocument.Parse(rawLogo);
|
||||
svg.Root.SetAttributeValue("x", CleanSvgVal(logoAttr.Value.X));
|
||||
svg.Root.SetAttributeValue("y", CleanSvgVal(logoAttr.Value.Y));
|
||||
svg.Root.SetAttributeValue("width", CleanSvgVal(logoAttr.Value.Width));
|
||||
svg.Root.SetAttributeValue("height", CleanSvgVal(logoAttr.Value.Height));
|
||||
svg.Root.SetAttributeValue("shape-rendering", "geometricPrecision");
|
||||
svgFile.AppendLine(svg.ToString(System.Xml.Linq.SaveOptions.DisableFormatting).Replace("svg:", ""));
|
||||
}
|
||||
}
|
||||
|
||||
svgFile.Append(@"</svg>");
|
||||
return svgFile.ToString();
|
||||
}
|
||||
|
||||
private bool IsBlockedByLogo(double x, double y, ImageAttributes? attr, double pixelPerModule)
|
||||
{
|
||||
return x + pixelPerModule >= attr.Value.X && x <= attr.Value.X + attr.Value.Width && y + pixelPerModule >= attr.Value.Y && y <= attr.Value.Y + attr.Value.Height;
|
||||
}
|
||||
|
||||
private ImageAttributes GetLogoAttributes(SvgLogo logo, Size viewBox)
|
||||
{
|
||||
var imgWidth = logo.GetIconSizePercent() / 100d * viewBox.Width;
|
||||
var imgHeight = logo.GetIconSizePercent() / 100d * viewBox.Height;
|
||||
var imgPosX = viewBox.Width / 2d - imgWidth / 2d;
|
||||
var imgPosY = viewBox.Height / 2d - imgHeight / 2d;
|
||||
return new ImageAttributes()
|
||||
{
|
||||
Width = imgWidth,
|
||||
Height = imgHeight,
|
||||
X = imgPosX,
|
||||
Y = imgPosY
|
||||
};
|
||||
}
|
||||
|
||||
private struct ImageAttributes
|
||||
{
|
||||
public double Width;
|
||||
public double Height;
|
||||
public double X;
|
||||
public double Y;
|
||||
}
|
||||
|
||||
private string CleanSvgVal(double input)
|
||||
{
|
||||
//Clean double values for international use/formats
|
||||
//We use explicitly "G15" to avoid differences between .NET full and Core platforms
|
||||
//https://stackoverflow.com/questions/64898117/tostring-has-a-different-behavior-between-net-462-and-net-core-3-1
|
||||
return input.ToString("G15", System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mode of sizing attribution on svg root node
|
||||
/// </summary>
|
||||
public enum SizingMode
|
||||
{
|
||||
WidthHeightAttribute,
|
||||
ViewBoxAttribute
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a logo graphic that can be rendered on a SvgQRCode
|
||||
/// </summary>
|
||||
public class SvgLogo
|
||||
{
|
||||
private string _logoData;
|
||||
private MediaType _mediaType;
|
||||
private int _iconSizePercent;
|
||||
private bool _fillLogoBackground;
|
||||
private object _logoRaw;
|
||||
private bool _isEmbedded;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create a logo object to be used in SvgQRCode renderer
|
||||
/// </summary>
|
||||
/// <param name="iconRasterized">Logo to be rendered as Bitmap/rasterized graphic</param>
|
||||
/// <param name="iconSizePercent">Degree of percentage coverage of the QR code by the logo</param>
|
||||
/// <param name="fillLogoBackground">If true, the background behind the logo will be cleaned</param>
|
||||
public SvgLogo(Bitmap iconRasterized, int iconSizePercent = 15, bool fillLogoBackground = true)
|
||||
{
|
||||
_iconSizePercent = iconSizePercent;
|
||||
using (var ms = new System.IO.MemoryStream())
|
||||
{
|
||||
using (var bitmap = new Bitmap(iconRasterized))
|
||||
{
|
||||
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
|
||||
_logoData = Convert.ToBase64String(ms.GetBuffer(), Base64FormattingOptions.None);
|
||||
}
|
||||
}
|
||||
_mediaType = MediaType.PNG;
|
||||
_fillLogoBackground = fillLogoBackground;
|
||||
_logoRaw = iconRasterized;
|
||||
_isEmbedded = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a logo object to be used in SvgQRCode renderer
|
||||
/// </summary>
|
||||
/// <param name="iconVectorized">Logo to be rendered as SVG/vectorized graphic/string</param>
|
||||
/// <param name="iconSizePercent">Degree of percentage coverage of the QR code by the logo</param>
|
||||
/// <param name="fillLogoBackground">If true, the background behind the logo will be cleaned</param>
|
||||
/// <param name="iconEmbedded">If true, the logo will embedded as native svg instead of embedding it as image-tag</param>
|
||||
public SvgLogo(string iconVectorized, int iconSizePercent = 15, bool fillLogoBackground = true, bool iconEmbedded = true)
|
||||
{
|
||||
_iconSizePercent = iconSizePercent;
|
||||
_logoData = Convert.ToBase64String(Encoding.UTF8.GetBytes(iconVectorized), Base64FormattingOptions.None);
|
||||
_mediaType = MediaType.SVG;
|
||||
_fillLogoBackground = fillLogoBackground;
|
||||
_logoRaw = iconVectorized;
|
||||
_isEmbedded = iconEmbedded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the raw logo's data
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public object GetRawLogo()
|
||||
{
|
||||
return _logoRaw;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines, if the logo shall be natively embedded.
|
||||
/// true=native svg embedding, false=embedding via image-tag
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsEmbedded()
|
||||
{
|
||||
return _isEmbedded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the media type of the logo
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MediaType GetMediaType()
|
||||
{
|
||||
return _mediaType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the logo as data-uri
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetDataUri()
|
||||
{
|
||||
return $"data:{_mediaType.GetStringValue()};base64,{_logoData}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns how much of the QR code should be covered by the logo (in percent)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int GetIconSizePercent()
|
||||
{
|
||||
return _iconSizePercent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns if the background of the logo should be cleaned (no QR modules will be rendered behind the logo)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool FillLogoBackground()
|
||||
{
|
||||
return _fillLogoBackground;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Media types for SvgLogos
|
||||
/// </summary>
|
||||
public enum MediaType : int
|
||||
{
|
||||
[StringValue("image/png")]
|
||||
PNG = 0,
|
||||
[StringValue("image/svg+xml")]
|
||||
SVG = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class SvgQRCodeHelper
|
||||
{
|
||||
public static string GetQRCode(string plainText, int pixelsPerModule, string darkColorHex, string lightColorHex, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo logo = null)
|
||||
{
|
||||
using (var qrGenerator = new QRCodeGenerator())
|
||||
using (var qrCodeData = qrGenerator.CreateQrCode(plainText, eccLevel, forceUtf8, utf8BOM, eciMode, requestedVersion))
|
||||
using (var qrCode = new SvgQRCode(qrCodeData))
|
||||
return qrCode.GetGraphic(pixelsPerModule, darkColorHex, lightColorHex, drawQuietZones, sizingMode, logo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
51
vCardEditor/Model/vCardPropeties.cs
Normal file
51
vCardEditor/Model/vCardPropeties.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
namespace vCardEditor.Model
|
||||
{
|
||||
public enum vCardPropeties
|
||||
{
|
||||
ADR = 0,
|
||||
AGENT,
|
||||
ANNIVERSARY,
|
||||
BDAY,
|
||||
BEGIN,
|
||||
CALADRURI,
|
||||
CALURI,
|
||||
CATEGORIES,
|
||||
CLASS,
|
||||
CLIENTPIDMAP,
|
||||
EMAIL,
|
||||
END,
|
||||
FBURL,
|
||||
FN,
|
||||
GENDER,
|
||||
GEO,
|
||||
IMPP,
|
||||
KEY,
|
||||
KIND,
|
||||
LABEL,
|
||||
LANG,
|
||||
LOGO,
|
||||
MAILER,
|
||||
MEMBER,
|
||||
N,
|
||||
NAME,
|
||||
NICKNAME,
|
||||
NOTE,
|
||||
ORG,
|
||||
PHOTO,
|
||||
PRODID,
|
||||
PROFILE,
|
||||
RELATED,
|
||||
REV,
|
||||
ROLE,
|
||||
SORTSTRING,
|
||||
SOUND,
|
||||
SOURCE,
|
||||
TEL,
|
||||
TITLE,
|
||||
TZ,
|
||||
UID,
|
||||
URL,
|
||||
VERSION,
|
||||
XML
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ namespace VCFEditor.Presenter
|
||||
_view.LoadForm += LoadFormHandler;
|
||||
_view.AddContact += AddContactHandler;
|
||||
_view.NewFileOpened += NewFileOpenedHandler;
|
||||
_view.BeforeOpeningNewFile += BeforeOpeningNewFileHandler;
|
||||
_view.SaveContactsSelected += SaveContactsHandler;
|
||||
_view.ChangeContactsSelected += ChangeContactSelectedHandler;
|
||||
_view.DeleteContact += DeleteContactHandler;
|
||||
@@ -34,13 +33,20 @@ namespace VCFEditor.Presenter
|
||||
_view.CloseForm += CloseFormHandler;
|
||||
_view.ModifyImage += ModifyImageHandler;
|
||||
_view.ExportImage += ExportImageHandler;
|
||||
_view.ExportQR += ExportQRHandler;
|
||||
_view.AddressAdded += AddressAddedHandler;
|
||||
_view.AddressModified += AddressModifiedHandler;
|
||||
_view.AddressRemoved += AddressRemovedHandler;
|
||||
_view.CopyTextToClipboardEvent += CopyTextToClipboardHandler;
|
||||
_view.AddExtraField += _view_AddExtraField;
|
||||
|
||||
}
|
||||
|
||||
private void _view_AddExtraField(object sender, EventArg<vCardPropeties> e)
|
||||
{
|
||||
_view.AddExtraTextGroup(e.Data, string.Empty);
|
||||
}
|
||||
|
||||
private void CopyTextToClipboardHandler(object sender, EventArgs e)
|
||||
{
|
||||
if (_view.SelectedContactIndex < 0)
|
||||
@@ -55,13 +61,14 @@ namespace VCFEditor.Presenter
|
||||
}
|
||||
private void LoadFormHandler(object sender, EventArg<FormState> e)
|
||||
{
|
||||
e.Data = ConfigRepository.Instance.FormState;
|
||||
_view.LoadIntialState(ConfigRepository.Instance.FormState);
|
||||
var paths = Environment.GetCommandLineArgs();
|
||||
if (paths.Length > 1)
|
||||
{
|
||||
var evt = new EventArg<string>(paths[1]);
|
||||
NewFileOpenedHandler(sender, evt);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +116,18 @@ namespace VCFEditor.Presenter
|
||||
}
|
||||
}
|
||||
|
||||
private void ExportQRHandler(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (_view.SelectedContactIndex > -1)
|
||||
{
|
||||
var card = _repository.Contacts[_view.SelectedContactIndex].card;
|
||||
string content = _repository.GenerateStringFromVCard(card);
|
||||
|
||||
_view.DisplayQRCode(content);
|
||||
}
|
||||
}
|
||||
|
||||
private void ModifyImageHandler(object sender, EventArg<string> e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(e.Data) )
|
||||
@@ -170,7 +189,7 @@ namespace VCFEditor.Presenter
|
||||
|
||||
}
|
||||
|
||||
private void BeforeOpeningNewFileHandler(object sender, EventArgs e)
|
||||
private void BeforeOpeningNewFileHandler()
|
||||
{
|
||||
if (_repository.Contacts != null && _repository.dirty)
|
||||
{
|
||||
@@ -181,7 +200,7 @@ namespace VCFEditor.Presenter
|
||||
}
|
||||
public void NewFileOpenedHandler(object sender, EventArg<string> e)
|
||||
{
|
||||
BeforeOpeningNewFileHandler(sender, e);
|
||||
BeforeOpeningNewFileHandler();
|
||||
|
||||
string path = e.Data;
|
||||
if (string.IsNullOrEmpty(path))
|
||||
@@ -202,9 +221,11 @@ namespace VCFEditor.Presenter
|
||||
MostRecentUsedFiles.Enqueue(path);
|
||||
_view.UpdateMRUMenu(MostRecentUsedFiles);
|
||||
}
|
||||
|
||||
_repository.LoadContacts(path);
|
||||
_view.DisplayContacts(_repository.Contacts);
|
||||
|
||||
if (!_repository.LoadContacts(path))
|
||||
_view.DisplayMessage("File seems missing or corrupted!", "Error");
|
||||
else
|
||||
_view.DisplayContacts(_repository.Contacts);
|
||||
}
|
||||
|
||||
|
||||
@@ -212,6 +233,7 @@ namespace VCFEditor.Presenter
|
||||
|
||||
public void ChangeContactSelectedHandler(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (_view.SelectedContactIndex > -1)
|
||||
{
|
||||
vCard card = _repository.Contacts[_view.SelectedContactIndex].card;
|
||||
|
||||
@@ -32,5 +32,4 @@ using System.Runtime.InteropServices;
|
||||
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
|
||||
// en utilisant '*', comme indiqué ci-dessous :
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.4.0.*")]
|
||||
//[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("0.5.5")]
|
||||
|
||||
10
vCardEditor/Properties/Resources.Designer.cs
generated
10
vCardEditor/Properties/Resources.Designer.cs
generated
@@ -79,5 +79,15 @@ namespace vCardEditor.Properties {
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap nuget_icon {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("nuget-icon", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,4 +124,7 @@
|
||||
<data name="Close" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\assests\Close.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="nuget-icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Libs\QRCoder\Assets\nuget-icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1,4 +1,21 @@
|
||||
0.5
|
||||
0.5.5
|
||||
redisgn the extra tab
|
||||
Fix some bugs
|
||||
|
||||
0.5.4
|
||||
Fix a regression when saving Phones, Website, Email
|
||||
added the update button in the about dialog to check the latest version.
|
||||
|
||||
0.5.3
|
||||
Support of QR Code.
|
||||
|
||||
0.5.2
|
||||
added an option to Right-click on a ".vcf"" file –> Open With —> vCardEditor
|
||||
|
||||
0.5.1
|
||||
Fixed clearing fields when changing contact
|
||||
|
||||
0.5
|
||||
A reworked control for adding/modifying or removing addresses.
|
||||
|
||||
0.4
|
||||
|
||||
@@ -33,7 +33,10 @@ namespace vCardEditor.Repository
|
||||
public bool OverWrite { get; set; }
|
||||
[Description("Maximum entries for MRU ")]
|
||||
public int Maximum { get; set; }
|
||||
|
||||
|
||||
[Description("Url for checking application version")]
|
||||
public string VersionUrl { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public FixedList Paths { get; set; }
|
||||
|
||||
@@ -86,7 +89,8 @@ namespace vCardEditor.Repository
|
||||
configData = new ConfigRepository
|
||||
{
|
||||
Maximum = MAX_RECENT_FILES,
|
||||
Paths = new FixedList(MAX_RECENT_FILES)
|
||||
Paths = new FixedList(MAX_RECENT_FILES),
|
||||
VersionUrl = "https://raw.githubusercontent.com/abdelkader/vCardEditor/master/vCardEditor/Releases.txt"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -49,11 +49,18 @@ namespace VCFEditor.Repository
|
||||
_fileHandler = fileHandler;
|
||||
}
|
||||
|
||||
public SortableBindingList<Contact> LoadContacts(string fileName)
|
||||
public bool LoadContacts(string fileName)
|
||||
{
|
||||
Contacts.Clear();
|
||||
|
||||
this.fileName = fileName;
|
||||
|
||||
if (!_fileHandler.FileExist(fileName))
|
||||
{
|
||||
OriginalContactList = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
string[] lines = _fileHandler.ReadAllLines(fileName);
|
||||
|
||||
StringBuilder RawContent = new StringBuilder();
|
||||
@@ -62,20 +69,37 @@ namespace VCFEditor.Repository
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
RawContent.AppendLine(lines[i]);
|
||||
if (string.Equals(lines[i].TrimEnd(), "END:VCARD", StringComparison.OrdinalIgnoreCase))
|
||||
try
|
||||
{
|
||||
contact.card = ParseRawContent(RawContent);
|
||||
Contacts.Add(contact);
|
||||
contact = new Contact();
|
||||
RawContent.Length = 0;
|
||||
if (string.Equals(lines[i].TrimEnd(), "END:VCARD", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
contact.card = ParseRawContent(RawContent);
|
||||
Contacts.Add(contact);
|
||||
contact = new Contact();
|
||||
RawContent.Length = 0;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
OriginalContactList = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
OriginalContactList = Contacts;
|
||||
return Contacts;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private vCard ParseRawContent(StringBuilder rawContent)
|
||||
{
|
||||
vCard card = null;
|
||||
|
||||
using (StringReader reader = new StringReader(rawContent.ToString()))
|
||||
card = new vCard(reader);
|
||||
|
||||
return card;
|
||||
}
|
||||
|
||||
public void AddEmptyContact()
|
||||
{
|
||||
if (_contacts != null && _contacts.Count > 0)
|
||||
@@ -111,9 +135,9 @@ namespace VCFEditor.Repository
|
||||
|
||||
//Clean the flag for every contact, even the deleted ones.
|
||||
entry.isDirty = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
_dirty = false;
|
||||
_fileHandler.WriteAllText(fileName, sb.ToString());
|
||||
}
|
||||
|
||||
@@ -149,28 +173,6 @@ namespace VCFEditor.Repository
|
||||
|
||||
}
|
||||
|
||||
private vCard ParseRawContent(StringBuilder rawContent)
|
||||
{
|
||||
vCard card = null;
|
||||
|
||||
using (MemoryStream s = GenerateStreamFromString(rawContent.ToString()))
|
||||
using (TextReader streamReader = new StreamReader(s, Encoding.UTF8))
|
||||
{
|
||||
card = new vCard(streamReader);
|
||||
}
|
||||
|
||||
return card;
|
||||
}
|
||||
|
||||
private MemoryStream GenerateStreamFromString(string s)
|
||||
{
|
||||
MemoryStream stream = new MemoryStream();
|
||||
StreamWriter writer = new StreamWriter(stream);
|
||||
writer.Write(s);
|
||||
writer.Flush();
|
||||
stream.Position = 0;
|
||||
return stream;
|
||||
}
|
||||
|
||||
public SortableBindingList<Contact> FilterContacts(string filter)
|
||||
{
|
||||
@@ -203,9 +205,28 @@ namespace VCFEditor.Repository
|
||||
SaveEmail(NewCard, card);
|
||||
SaveWebUrl(NewCard, card);
|
||||
SaveAddresses(NewCard, card);
|
||||
SaveExtraField(NewCard, card);
|
||||
SaveExtraPhones(NewCard, card);
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveExtraPhones(vCard newCard, vCard card)
|
||||
{
|
||||
card.Phones.Clear();
|
||||
foreach (var item in newCard.Phones)
|
||||
card.Phones.Add(new vCardPhone(item.FullNumber, item.PhoneType));
|
||||
|
||||
}
|
||||
|
||||
private void SaveExtraField(vCard newCard, vCard card)
|
||||
{
|
||||
card.Notes.Clear();
|
||||
foreach (var item in newCard.Notes)
|
||||
card.Notes.Add(new vCardNote(item.Text));
|
||||
|
||||
card.Organization = newCard.Organization;
|
||||
}
|
||||
|
||||
private void SaveAddresses(vCard NewCard, vCard card)
|
||||
{
|
||||
foreach (var item in NewCard.DeliveryAddresses)
|
||||
@@ -218,6 +239,8 @@ namespace VCFEditor.Repository
|
||||
adr.PostalCode = item.PostalCode;
|
||||
adr.Region = item.Region;
|
||||
adr.Street = item.Street;
|
||||
adr.ExtendedAddress = item.ExtendedAddress;
|
||||
adr.PostOfficeBox = item.PostOfficeBox;
|
||||
}
|
||||
else
|
||||
card.DeliveryAddresses.Add(new vCardDeliveryAddress(item.Street, item.City, item.Region, item.Country,
|
||||
@@ -332,10 +355,11 @@ namespace VCFEditor.Repository
|
||||
public string GenerateStringFromVCard(vCard card)
|
||||
{
|
||||
vCardStandardWriter writer = new vCardStandardWriter();
|
||||
TextWriter tw = new StringWriter();
|
||||
writer.Write(card, tw);
|
||||
|
||||
return tw.ToString();
|
||||
using (TextWriter tw = new StringWriter())
|
||||
{
|
||||
writer.Write(card, tw);
|
||||
return tw.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public void ModifyImage(int index, vCardPhoto photo)
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace VCFEditor.Repository
|
||||
bool dirty { get; }
|
||||
string fileName { get; set; }
|
||||
SortableBindingList<Contact> Contacts { get; set; }
|
||||
SortableBindingList<Contact> LoadContacts(string fileName);
|
||||
bool LoadContacts(string fileName);
|
||||
SortableBindingList<Contact> FilterContacts(string p);
|
||||
void SaveContactsToFile(string fileName);
|
||||
void DeleteContact();
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Thought.vCards
|
||||
/// </remarks>
|
||||
/// <seealso cref="vCardEmailAddressCollection"/>
|
||||
/// <seealso cref="vCardEmailAddressType"/>
|
||||
public class vCardEmailAddress
|
||||
public class vCardEmailAddress : vCardRoot
|
||||
{
|
||||
|
||||
private string address;
|
||||
@@ -120,6 +120,16 @@ namespace Thought.vCards
|
||||
|
||||
}
|
||||
|
||||
public override void ChangeContent(string text)
|
||||
{
|
||||
this.address = text;
|
||||
}
|
||||
|
||||
public override string GetNameType()
|
||||
{
|
||||
return EmailType.ToString();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Builds a string that represents the email address.
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Thought.vCards
|
||||
/// <seealso cref="vCardPhoneCollection"/>
|
||||
/// <seealso cref="vCardPhoneTypes"/>
|
||||
[Serializable]
|
||||
public class vCardPhone
|
||||
public class vCardPhone : vCardRoot
|
||||
{
|
||||
|
||||
private string fullNumber;
|
||||
@@ -42,6 +42,10 @@ namespace Thought.vCards
|
||||
this.fullNumber = fullNumber;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.fullNumber;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="vCardPhone"/> with the specified number and subtype.
|
||||
@@ -452,6 +456,15 @@ namespace Thought.vCards
|
||||
}
|
||||
}
|
||||
|
||||
public override void ChangeContent(string text)
|
||||
{
|
||||
this.FullNumber = text;
|
||||
}
|
||||
|
||||
public override string GetNameType()
|
||||
{
|
||||
return PhoneType.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
8
vCardEditor/Thought.vCards/vCardRoot.cs
Normal file
8
vCardEditor/Thought.vCards/vCardRoot.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Thought.vCards
|
||||
{
|
||||
abstract public class vCardRoot
|
||||
{
|
||||
abstract public void ChangeContent(string text);
|
||||
abstract public string GetNameType();
|
||||
}
|
||||
}
|
||||
@@ -311,8 +311,8 @@ namespace Thought.vCards
|
||||
|
||||
vCardValueCollection values = new vCardValueCollection(';');
|
||||
|
||||
values.Add(string.Empty);
|
||||
values.Add(string.Empty);
|
||||
values.Add(address.PostOfficeBox);
|
||||
values.Add(address.ExtendedAddress);
|
||||
values.Add(!string.IsNullOrEmpty(address.Street) ? address.Street.Replace("\r\n", "\n") : string.Empty);
|
||||
values.Add(address.City);
|
||||
values.Add(address.Region);
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Thought.vCards
|
||||
/// </summary>
|
||||
/// <seealso cref="vCardWebsiteCollection"/>
|
||||
/// <seealso cref="vCardWebsiteTypes"/>
|
||||
public class vCardWebsite
|
||||
public class vCardWebsite : vCardRoot
|
||||
{
|
||||
|
||||
private string url;
|
||||
@@ -154,6 +154,16 @@ namespace Thought.vCards
|
||||
}
|
||||
}
|
||||
|
||||
public override void ChangeContent(string text)
|
||||
{
|
||||
this.url = text;
|
||||
}
|
||||
|
||||
public override string GetNameType()
|
||||
{
|
||||
return WebsiteType.ToString();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string representation (URL) of the web site.
|
||||
|
||||
64
vCardEditor/View/AboutDialog.Designer.cs
generated
64
vCardEditor/View/AboutDialog.Designer.cs
generated
@@ -36,36 +36,42 @@
|
||||
this.labelCompanyName = new System.Windows.Forms.Label();
|
||||
this.textBoxDescription = new System.Windows.Forms.TextBox();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.updateButton = new System.Windows.Forms.Button();
|
||||
this.tableLayoutPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tableLayoutPanel
|
||||
//
|
||||
this.tableLayoutPanel.ColumnCount = 2;
|
||||
this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 27.81775F));
|
||||
this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 72.18225F));
|
||||
this.tableLayoutPanel.ColumnCount = 3;
|
||||
this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 32.31441F));
|
||||
this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 67.68559F));
|
||||
this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 119F));
|
||||
this.tableLayoutPanel.Controls.Add(this.logoPictureBox, 0, 0);
|
||||
this.tableLayoutPanel.Controls.Add(this.labelProductName, 1, 0);
|
||||
this.tableLayoutPanel.Controls.Add(this.labelVersion, 1, 1);
|
||||
this.tableLayoutPanel.Controls.Add(this.labelCopyright, 1, 2);
|
||||
this.tableLayoutPanel.Controls.Add(this.labelCompanyName, 1, 3);
|
||||
this.tableLayoutPanel.Controls.Add(this.textBoxDescription, 1, 4);
|
||||
this.tableLayoutPanel.Controls.Add(this.okButton, 1, 5);
|
||||
this.tableLayoutPanel.Controls.Add(this.okButton, 2, 5);
|
||||
this.tableLayoutPanel.Controls.Add(this.updateButton, 1, 5);
|
||||
this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel.Location = new System.Drawing.Point(12, 11);
|
||||
this.tableLayoutPanel.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.tableLayoutPanel.Name = "tableLayoutPanel";
|
||||
this.tableLayoutPanel.RowCount = 6;
|
||||
this.tableLayoutPanel.RowCount = 7;
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 47.93651F));
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.69841F));
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 8F));
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.tableLayoutPanel.Size = new System.Drawing.Size(556, 326);
|
||||
this.tableLayoutPanel.TabIndex = 0;
|
||||
//
|
||||
@@ -76,69 +82,74 @@
|
||||
this.logoPictureBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.logoPictureBox.Name = "logoPictureBox";
|
||||
this.tableLayoutPanel.SetRowSpan(this.logoPictureBox, 6);
|
||||
this.logoPictureBox.Size = new System.Drawing.Size(145, 121);
|
||||
this.logoPictureBox.Size = new System.Drawing.Size(133, 121);
|
||||
this.logoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.logoPictureBox.TabIndex = 12;
|
||||
this.logoPictureBox.TabStop = false;
|
||||
//
|
||||
// labelProductName
|
||||
//
|
||||
this.tableLayoutPanel.SetColumnSpan(this.labelProductName, 2);
|
||||
this.labelProductName.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.labelProductName.Location = new System.Drawing.Point(162, 0);
|
||||
this.labelProductName.Location = new System.Drawing.Point(149, 0);
|
||||
this.labelProductName.Margin = new System.Windows.Forms.Padding(8, 0, 4, 0);
|
||||
this.labelProductName.MaximumSize = new System.Drawing.Size(0, 21);
|
||||
this.labelProductName.Name = "labelProductName";
|
||||
this.labelProductName.Size = new System.Drawing.Size(390, 21);
|
||||
this.labelProductName.Size = new System.Drawing.Size(403, 21);
|
||||
this.labelProductName.TabIndex = 19;
|
||||
this.labelProductName.Text = "Nom du produit";
|
||||
this.labelProductName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// labelVersion
|
||||
//
|
||||
this.tableLayoutPanel.SetColumnSpan(this.labelVersion, 2);
|
||||
this.labelVersion.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.labelVersion.Location = new System.Drawing.Point(162, 32);
|
||||
this.labelVersion.Location = new System.Drawing.Point(149, 31);
|
||||
this.labelVersion.Margin = new System.Windows.Forms.Padding(8, 0, 4, 0);
|
||||
this.labelVersion.MaximumSize = new System.Drawing.Size(0, 21);
|
||||
this.labelVersion.Name = "labelVersion";
|
||||
this.labelVersion.Size = new System.Drawing.Size(390, 21);
|
||||
this.labelVersion.Size = new System.Drawing.Size(403, 21);
|
||||
this.labelVersion.TabIndex = 0;
|
||||
this.labelVersion.Text = "Version";
|
||||
this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// labelCopyright
|
||||
//
|
||||
this.tableLayoutPanel.SetColumnSpan(this.labelCopyright, 2);
|
||||
this.labelCopyright.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.labelCopyright.Location = new System.Drawing.Point(162, 64);
|
||||
this.labelCopyright.Location = new System.Drawing.Point(149, 62);
|
||||
this.labelCopyright.Margin = new System.Windows.Forms.Padding(8, 0, 4, 0);
|
||||
this.labelCopyright.MaximumSize = new System.Drawing.Size(0, 21);
|
||||
this.labelCopyright.Name = "labelCopyright";
|
||||
this.labelCopyright.Size = new System.Drawing.Size(390, 21);
|
||||
this.labelCopyright.Size = new System.Drawing.Size(403, 21);
|
||||
this.labelCopyright.TabIndex = 21;
|
||||
this.labelCopyright.Text = "Copyright";
|
||||
this.labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// labelCompanyName
|
||||
//
|
||||
this.tableLayoutPanel.SetColumnSpan(this.labelCompanyName, 2);
|
||||
this.labelCompanyName.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.labelCompanyName.Location = new System.Drawing.Point(162, 96);
|
||||
this.labelCompanyName.Location = new System.Drawing.Point(149, 93);
|
||||
this.labelCompanyName.Margin = new System.Windows.Forms.Padding(8, 0, 4, 0);
|
||||
this.labelCompanyName.MaximumSize = new System.Drawing.Size(0, 21);
|
||||
this.labelCompanyName.Name = "labelCompanyName";
|
||||
this.labelCompanyName.Size = new System.Drawing.Size(390, 21);
|
||||
this.labelCompanyName.Size = new System.Drawing.Size(403, 21);
|
||||
this.labelCompanyName.TabIndex = 22;
|
||||
this.labelCompanyName.Text = "Nom de la société";
|
||||
this.labelCompanyName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// textBoxDescription
|
||||
//
|
||||
this.tableLayoutPanel.SetColumnSpan(this.textBoxDescription, 2);
|
||||
this.textBoxDescription.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.textBoxDescription.Location = new System.Drawing.Point(162, 132);
|
||||
this.textBoxDescription.Location = new System.Drawing.Point(149, 128);
|
||||
this.textBoxDescription.Margin = new System.Windows.Forms.Padding(8, 4, 4, 4);
|
||||
this.textBoxDescription.Multiline = true;
|
||||
this.textBoxDescription.Name = "textBoxDescription";
|
||||
this.textBoxDescription.ReadOnly = true;
|
||||
this.textBoxDescription.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.textBoxDescription.Size = new System.Drawing.Size(390, 155);
|
||||
this.textBoxDescription.Size = new System.Drawing.Size(403, 143);
|
||||
this.textBoxDescription.TabIndex = 23;
|
||||
this.textBoxDescription.TabStop = false;
|
||||
this.textBoxDescription.Text = "Description";
|
||||
@@ -147,13 +158,23 @@
|
||||
//
|
||||
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.okButton.Location = new System.Drawing.Point(452, 295);
|
||||
this.okButton.Location = new System.Drawing.Point(442, 282);
|
||||
this.okButton.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(100, 27);
|
||||
this.okButton.Size = new System.Drawing.Size(110, 29);
|
||||
this.okButton.TabIndex = 24;
|
||||
this.okButton.Text = "&OK";
|
||||
//
|
||||
// updateButton
|
||||
//
|
||||
this.updateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.updateButton.Location = new System.Drawing.Point(312, 283);
|
||||
this.updateButton.Name = "updateButton";
|
||||
this.updateButton.Size = new System.Drawing.Size(121, 29);
|
||||
this.updateButton.TabIndex = 25;
|
||||
this.updateButton.Text = "Check update...";
|
||||
this.updateButton.Click += new System.EventHandler(this.updateButton_Click);
|
||||
//
|
||||
// AboutDialog
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
@@ -188,5 +209,6 @@
|
||||
private System.Windows.Forms.Label labelCompanyName;
|
||||
private System.Windows.Forms.TextBox textBoxDescription;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button updateButton;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using vCardEditor.Repository;
|
||||
|
||||
namespace vCardEditor.View
|
||||
{
|
||||
@@ -100,5 +104,36 @@ namespace vCardEditor.View
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
private async void updateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var client = new WebClient())
|
||||
{
|
||||
string result = await client.DownloadStringTaskAsync(ConfigRepository.Instance.VersionUrl);
|
||||
using (var reader = new StringReader(result))
|
||||
{
|
||||
string InternetVersion = reader.ReadLine();
|
||||
string AssemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
Version v1 = new Version(InternetVersion);
|
||||
Version v2 = new Version(AssemblyVersion);
|
||||
|
||||
if (v1.CompareTo(v2) > 0)
|
||||
MessageBox.Show(string.Format("New version {0} found!", result), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
else
|
||||
MessageBox.Show("You have the latest version!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (WebException )
|
||||
{
|
||||
MessageBox.Show("Could not download version information from GitHub.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
catch (Exception )
|
||||
{
|
||||
MessageBox.Show("Error processing version information.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
19
vCardEditor/View/Customs/AddressBox.Designer.cs
generated
19
vCardEditor/View/Customs/AddressBox.Designer.cs
generated
@@ -60,12 +60,12 @@ namespace vCardEditor.View.Customs
|
||||
//
|
||||
// ExtAdressLabel
|
||||
//
|
||||
this.ExtAdressLabel.Location = new System.Drawing.Point(1, 42);
|
||||
this.ExtAdressLabel.Location = new System.Drawing.Point(4, 45);
|
||||
this.ExtAdressLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.ExtAdressLabel.Name = "ExtAdressLabel";
|
||||
this.ExtAdressLabel.Size = new System.Drawing.Size(87, 23);
|
||||
this.ExtAdressLabel.Size = new System.Drawing.Size(40, 23);
|
||||
this.ExtAdressLabel.TabIndex = 26;
|
||||
this.ExtAdressLabel.Text = "Ext Address:";
|
||||
this.ExtAdressLabel.Text = "Ext:";
|
||||
this.ExtAdressLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// StreetLabel
|
||||
@@ -93,14 +93,13 @@ namespace vCardEditor.View.Customs
|
||||
//
|
||||
// POBoxLabel
|
||||
//
|
||||
this.POBoxLabel.Location = new System.Drawing.Point(334, 75);
|
||||
this.POBoxLabel.Location = new System.Drawing.Point(338, 75);
|
||||
this.POBoxLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.POBoxLabel.Name = "POBoxLabel";
|
||||
this.POBoxLabel.Size = new System.Drawing.Size(59, 23);
|
||||
this.POBoxLabel.Size = new System.Drawing.Size(38, 23);
|
||||
this.POBoxLabel.TabIndex = 16;
|
||||
this.POBoxLabel.Text = "PO Box:";
|
||||
this.POBoxLabel.Text = "PO :";
|
||||
this.POBoxLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
|
||||
//
|
||||
// CountryValue
|
||||
//
|
||||
@@ -129,7 +128,7 @@ namespace vCardEditor.View.Customs
|
||||
//
|
||||
this.POBoxValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.POBoxValue.Location = new System.Drawing.Point(397, 75);
|
||||
this.POBoxValue.Location = new System.Drawing.Point(397, 76);
|
||||
this.POBoxValue.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.POBoxValue.Name = "POBoxValue";
|
||||
this.POBoxValue.oldText = null;
|
||||
@@ -140,7 +139,7 @@ namespace vCardEditor.View.Customs
|
||||
//
|
||||
// CityLabel
|
||||
//
|
||||
this.CityLabel.Location = new System.Drawing.Point(338, 45);
|
||||
this.CityLabel.Location = new System.Drawing.Point(338, 46);
|
||||
this.CityLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.CityLabel.Name = "CityLabel";
|
||||
this.CityLabel.Size = new System.Drawing.Size(32, 23);
|
||||
@@ -176,7 +175,7 @@ namespace vCardEditor.View.Customs
|
||||
//
|
||||
// StateLabel
|
||||
//
|
||||
this.StateLabel.Location = new System.Drawing.Point(17, 74);
|
||||
this.StateLabel.Location = new System.Drawing.Point(2, 74);
|
||||
this.StateLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.StateLabel.Name = "StateLabel";
|
||||
this.StateLabel.Size = new System.Drawing.Size(61, 23);
|
||||
|
||||
98
vCardEditor/View/Customs/CustumInputDialog.Designer.cs
generated
Normal file
98
vCardEditor/View/Customs/CustumInputDialog.Designer.cs
generated
Normal file
@@ -0,0 +1,98 @@
|
||||
|
||||
namespace vCardEditor.View.Customs
|
||||
{
|
||||
partial class CustumInputDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.btnOK = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.tbInput = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnOK
|
||||
//
|
||||
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.btnOK.Location = new System.Drawing.Point(252, 67);
|
||||
this.btnOK.Name = "btnOK";
|
||||
this.btnOK.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnOK.TabIndex = 0;
|
||||
this.btnOK.Text = "OK";
|
||||
this.btnOK.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.button2.Location = new System.Drawing.Point(171, 67);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(75, 23);
|
||||
this.button2.TabIndex = 1;
|
||||
this.button2.Text = "Cancel";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tbInput
|
||||
//
|
||||
this.tbInput.Location = new System.Drawing.Point(80, 26);
|
||||
this.tbInput.Name = "tbInput";
|
||||
this.tbInput.Size = new System.Drawing.Size(247, 22);
|
||||
this.tbInput.TabIndex = 0;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(13, 30);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(51, 17);
|
||||
this.label1.TabIndex = 3;
|
||||
this.label1.Text = "Label :";
|
||||
//
|
||||
// CustumInputDialog
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(344, 102);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.tbInput);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.btnOK);
|
||||
this.Name = "CustumInputDialog";
|
||||
this.Text = "Label Dialog";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.CustumInputDialog_FormClosing);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btnOK;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.TextBox tbInput;
|
||||
private System.Windows.Forms.Label label1;
|
||||
}
|
||||
}
|
||||
21
vCardEditor/View/Customs/CustumInputDialog.cs
Normal file
21
vCardEditor/View/Customs/CustumInputDialog.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace vCardEditor.View.Customs
|
||||
{
|
||||
public partial class CustumInputDialog : Form
|
||||
{
|
||||
public CustumInputDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public string input { get; set; }
|
||||
|
||||
private void CustumInputDialog_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
input = tbInput.Text;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 1.3
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
@@ -14,16 +14,17 @@
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">1.3</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1">this is my long string</data>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
[base64 mime encoded serialized .NET Framework object]
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
@@ -35,7 +36,7 @@
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used forserialized objects, and tells the
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
@@ -45,7 +46,7 @@
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
@@ -59,18 +60,37 @@
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
@@ -89,21 +109,12 @@
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.Name">
|
||||
<value>CollapseBox</value>
|
||||
</data>
|
||||
</root>
|
||||
158
vCardEditor/View/Customs/ExtendedPanel.Designer.cs
generated
Normal file
158
vCardEditor/View/Customs/ExtendedPanel.Designer.cs
generated
Normal file
@@ -0,0 +1,158 @@
|
||||
|
||||
namespace vCardEditor.View.Customs
|
||||
{
|
||||
partial class ExtendedPanel
|
||||
{
|
||||
/// <summary>
|
||||
/// Variable nécessaire au concepteur.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Nettoyage des ressources utilisées.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true si les ressources managées doivent être supprimées ; sinon, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Code généré par le Concepteur de composants
|
||||
|
||||
/// <summary>
|
||||
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
|
||||
/// le contenu de cette méthode avec l'éditeur de code.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.gbExtended = new System.Windows.Forms.GroupBox();
|
||||
this.btnAddExtraText = new System.Windows.Forms.Button();
|
||||
this.PanelContent = new System.Windows.Forms.Panel();
|
||||
this.menuPhone = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.miCell = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.miHome = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.miWork = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuWeb = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.miEmail = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.miWeb = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.gbExtended.SuspendLayout();
|
||||
this.menuPhone.SuspendLayout();
|
||||
this.menuWeb.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// gbExtended
|
||||
//
|
||||
this.gbExtended.Controls.Add(this.btnAddExtraText);
|
||||
this.gbExtended.Controls.Add(this.PanelContent);
|
||||
this.gbExtended.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.gbExtended.Location = new System.Drawing.Point(0, 0);
|
||||
this.gbExtended.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.gbExtended.Name = "gbExtended";
|
||||
this.gbExtended.Padding = new System.Windows.Forms.Padding(4);
|
||||
this.gbExtended.Size = new System.Drawing.Size(367, 155);
|
||||
this.gbExtended.TabIndex = 3;
|
||||
this.gbExtended.TabStop = false;
|
||||
//
|
||||
// btnAddExtraText
|
||||
//
|
||||
this.btnAddExtraText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnAddExtraText.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.btnAddExtraText.Image = global::vCardEditor.Properties.Resources.Add;
|
||||
this.btnAddExtraText.Location = new System.Drawing.Point(316, -3);
|
||||
this.btnAddExtraText.Name = "btnAddExtraText";
|
||||
this.btnAddExtraText.Size = new System.Drawing.Size(39, 23);
|
||||
this.btnAddExtraText.TabIndex = 58;
|
||||
this.btnAddExtraText.UseVisualStyleBackColor = true;
|
||||
this.btnAddExtraText.Click += new System.EventHandler(this.btnAddExtraText_Click);
|
||||
//
|
||||
// PanelContent
|
||||
//
|
||||
this.PanelContent.AutoScroll = true;
|
||||
this.PanelContent.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.PanelContent.Location = new System.Drawing.Point(4, 19);
|
||||
this.PanelContent.Name = "PanelContent";
|
||||
this.PanelContent.Size = new System.Drawing.Size(359, 132);
|
||||
this.PanelContent.TabIndex = 0;
|
||||
//
|
||||
// menuPhone
|
||||
//
|
||||
this.menuPhone.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.menuPhone.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.miCell,
|
||||
this.miHome,
|
||||
this.miWork});
|
||||
this.menuPhone.Name = "contextMenuStrip1";
|
||||
this.menuPhone.Size = new System.Drawing.Size(120, 76);
|
||||
//
|
||||
// miCell
|
||||
//
|
||||
this.miCell.Name = "miCell";
|
||||
this.miCell.Size = new System.Drawing.Size(119, 24);
|
||||
this.miCell.Text = "Cell";
|
||||
//
|
||||
// miHome
|
||||
//
|
||||
this.miHome.Name = "miHome";
|
||||
this.miHome.Size = new System.Drawing.Size(119, 24);
|
||||
this.miHome.Text = "Home";
|
||||
//
|
||||
// miWork
|
||||
//
|
||||
this.miWork.Name = "miWork";
|
||||
this.miWork.Size = new System.Drawing.Size(119, 24);
|
||||
this.miWork.Text = "Work";
|
||||
//
|
||||
// menuWeb
|
||||
//
|
||||
this.menuWeb.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.menuWeb.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.miEmail,
|
||||
this.miWeb});
|
||||
this.menuWeb.Name = "contextMenuStrip1";
|
||||
this.menuWeb.Size = new System.Drawing.Size(211, 80);
|
||||
//
|
||||
// miEmail
|
||||
//
|
||||
this.miEmail.Name = "miEmail";
|
||||
this.miEmail.Size = new System.Drawing.Size(210, 24);
|
||||
this.miEmail.Text = "Email";
|
||||
//
|
||||
// miWeb
|
||||
//
|
||||
this.miWeb.Name = "miWeb";
|
||||
this.miWeb.Size = new System.Drawing.Size(210, 24);
|
||||
this.miWeb.Text = "Web";
|
||||
//
|
||||
// ExtendedPanel
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.gbExtended);
|
||||
this.Name = "ExtendedPanel";
|
||||
this.Size = new System.Drawing.Size(367, 155);
|
||||
this.gbExtended.ResumeLayout(false);
|
||||
this.menuPhone.ResumeLayout(false);
|
||||
this.menuWeb.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox gbExtended;
|
||||
private System.Windows.Forms.Button btnAddExtraText;
|
||||
private System.Windows.Forms.Panel PanelContent;
|
||||
private System.Windows.Forms.ContextMenuStrip menuPhone;
|
||||
private System.Windows.Forms.ToolStripMenuItem miCell;
|
||||
private System.Windows.Forms.ToolStripMenuItem miHome;
|
||||
private System.Windows.Forms.ToolStripMenuItem miWork;
|
||||
private System.Windows.Forms.ContextMenuStrip menuWeb;
|
||||
private System.Windows.Forms.ToolStripMenuItem miEmail;
|
||||
private System.Windows.Forms.ToolStripMenuItem miWeb;
|
||||
}
|
||||
}
|
||||
154
vCardEditor/View/Customs/ExtendedPanel.cs
Normal file
154
vCardEditor/View/Customs/ExtendedPanel.cs
Normal file
@@ -0,0 +1,154 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Thought.vCards;
|
||||
|
||||
namespace vCardEditor.View.Customs
|
||||
{
|
||||
|
||||
public partial class ExtendedPanel : UserControl
|
||||
{
|
||||
public event EventHandler ContentTextChanged;
|
||||
|
||||
public string Caption
|
||||
{
|
||||
get { return PanelContent.Text; }
|
||||
set { PanelContent.Text = value; }
|
||||
}
|
||||
|
||||
public PanelType panelType { get; set; }
|
||||
|
||||
public ExtendedPanel(PanelType _panel)
|
||||
{
|
||||
InitializeComponent();
|
||||
panelType = _panel;
|
||||
miCell.Click += MenuItemClickHandlers;
|
||||
miCell.Tag = new vCardPhone(string.Empty, vCardPhoneTypes.Cellular);
|
||||
|
||||
miHome.Tag = new vCardPhone(string.Empty, vCardPhoneTypes.Home);
|
||||
miHome.Click += MenuItemClickHandlers;
|
||||
|
||||
miWork.Tag = new vCardPhone(string.Empty, vCardPhoneTypes.Home);
|
||||
miWork.Click += MenuItemClickHandlers;
|
||||
|
||||
miEmail.Tag = new vCardEmailAddress(string.Empty, vCardEmailAddressType.Internet);
|
||||
miEmail.Click += MenuItemClickHandlers;
|
||||
|
||||
miWeb.Tag = new vCardWebsite(string.Empty, vCardWebsiteTypes.Personal);
|
||||
miWeb.Click += MenuItemClickHandlers;
|
||||
|
||||
//TODO : For Custom types
|
||||
//CustumInputDialog custom = new CustumInputDialog();
|
||||
//var res = custom.ShowDialog();
|
||||
//if (res == DialogResult.OK)
|
||||
//{
|
||||
// AddControl(custom.input, string.Empty);
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
private void MenuItemClickHandlers(object sender, EventArgs e)
|
||||
{
|
||||
var tag = (sender as ToolStripMenuItem).Tag;
|
||||
if (tag != null && tag is vCardRoot)
|
||||
AddControl(tag as vCardRoot);
|
||||
}
|
||||
|
||||
|
||||
private void btnAddExtraText_Click(object sender, EventArgs e)
|
||||
{
|
||||
Button btnSender = (Button)sender;
|
||||
Point ptLowerLeft = new Point(0, btnSender.Height);
|
||||
ptLowerLeft = btnSender.PointToScreen(ptLowerLeft);
|
||||
|
||||
switch (panelType)
|
||||
{
|
||||
case PanelType.Phone:
|
||||
menuPhone.Show(ptLowerLeft);
|
||||
break;
|
||||
case PanelType.Web:
|
||||
menuWeb.Show(ptLowerLeft);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void AddControl(vCardRoot card)
|
||||
{
|
||||
Point pt = GetCoordinatesForNewControl();
|
||||
|
||||
RemovableTextBox ctl = new RemovableTextBox(card);
|
||||
|
||||
ctl.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left;
|
||||
ctl.Location = pt;
|
||||
ctl.Width = PanelContent.Width - 20; //TODO : Calculte the right size of the scrollbar!
|
||||
|
||||
|
||||
ctl.BoutonRemoveClicked += RemoveControl;
|
||||
ctl.ContentTextChanged += (s, e) => ContentTextChanged?.Invoke(s, e);
|
||||
PanelContent.Controls.Add(ctl);
|
||||
}
|
||||
public List<vCardRoot> GetExtraFields()
|
||||
{
|
||||
List<vCardRoot> result = new List<vCardRoot>();
|
||||
|
||||
foreach (var item in PanelContent.Controls)
|
||||
{
|
||||
var ctl = item as RemovableTextBox;
|
||||
result.Add(ctl.Tag as vCardRoot);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void ClearFields()
|
||||
{
|
||||
if (PanelContent.Controls.Count > 0)
|
||||
PanelContent.Controls.Clear();
|
||||
}
|
||||
|
||||
private void RemoveControl(object sender, EventArgs e)
|
||||
{
|
||||
var par = (sender as Control).Parent;
|
||||
PanelContent.Controls.Remove(par);
|
||||
|
||||
ReplaceControls();
|
||||
}
|
||||
|
||||
private void ReplaceControls()
|
||||
{
|
||||
for (int i = 0; i < PanelContent.Controls.Count; i++)
|
||||
{
|
||||
var ctl = PanelContent.Controls[i];
|
||||
ctl.Location = new Point(5, (i * 30) + 10);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Point GetCoordinatesForNewControl()
|
||||
{
|
||||
Point pt;
|
||||
if (PanelContent.Controls.Count > 0)
|
||||
{
|
||||
var LastControl = PanelContent.Controls[PanelContent.Controls.Count - 1];
|
||||
pt = LastControl.Location;
|
||||
pt.Y += 30;
|
||||
}
|
||||
else
|
||||
pt = new Point(5, 10);
|
||||
|
||||
return pt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
126
vCardEditor/View/Customs/ExtendedPanel.resx
Normal file
126
vCardEditor/View/Customs/ExtendedPanel.resx
Normal file
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuPhone.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="menuWeb.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>203, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
84
vCardEditor/View/Customs/ExtraTextGroup.Designer.cs
generated
Normal file
84
vCardEditor/View/Customs/ExtraTextGroup.Designer.cs
generated
Normal file
@@ -0,0 +1,84 @@
|
||||
|
||||
namespace vCardEditor.View.UIToolbox
|
||||
{
|
||||
partial class ExtraTextGroup
|
||||
{
|
||||
/// <summary>
|
||||
/// Variable nécessaire au concepteur.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Nettoyage des ressources utilisées.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true si les ressources managées doivent être supprimées ; sinon, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Code généré par le Concepteur de composants
|
||||
|
||||
/// <summary>
|
||||
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
|
||||
/// le contenu de cette méthode avec l'éditeur de code.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.btnClose = new System.Windows.Forms.Button();
|
||||
this.txtContent = new vCardEditor.View.StateTextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnClose
|
||||
//
|
||||
this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnClose.BackgroundImage = global::vCardEditor.Properties.Resources.Close;
|
||||
this.btnClose.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.btnClose.Location = new System.Drawing.Point(594, 18);
|
||||
this.btnClose.Name = "btnClose";
|
||||
this.btnClose.Size = new System.Drawing.Size(23, 23);
|
||||
this.btnClose.TabIndex = 1;
|
||||
this.btnClose.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// txtContent
|
||||
//
|
||||
this.txtContent.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtContent.Location = new System.Drawing.Point(56, 4);
|
||||
this.txtContent.Multiline = true;
|
||||
this.txtContent.Name = "txtContent";
|
||||
this.txtContent.oldText = null;
|
||||
this.txtContent.Size = new System.Drawing.Size(532, 53);
|
||||
this.txtContent.TabIndex = 2;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(3, 7);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(0, 17);
|
||||
this.label2.TabIndex = 3;
|
||||
//
|
||||
// ExtraTextGroup
|
||||
//
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.txtContent);
|
||||
this.Controls.Add(this.btnClose);
|
||||
this.Name = "ExtraTextGroup";
|
||||
this.Size = new System.Drawing.Size(620, 67);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.Button btnClose;
|
||||
private StateTextBox txtContent;
|
||||
private System.Windows.Forms.Label label2;
|
||||
}
|
||||
}
|
||||
34
vCardEditor/View/Customs/ExtraTextGroup.cs
Normal file
34
vCardEditor/View/Customs/ExtraTextGroup.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using vCardEditor.Model;
|
||||
|
||||
namespace vCardEditor.View.UIToolbox
|
||||
{
|
||||
public partial class ExtraTextGroup : UserControl
|
||||
{
|
||||
public event EventHandler ControlDeleted;
|
||||
public event EventHandler TextChangedEvent;
|
||||
|
||||
public ExtraTextGroup()
|
||||
{
|
||||
InitializeComponent();
|
||||
txtContent.TextChanged += (s, e) => TextChangedEvent?.Invoke(s, e);
|
||||
btnClose.Click += (s, e) => ControlDeleted?.Invoke(s, e);
|
||||
|
||||
}
|
||||
|
||||
public vCardPropeties CardProp { get; set; }
|
||||
|
||||
public string Caption
|
||||
{
|
||||
get { return label2.Text; }
|
||||
set { label2.Text = value; }
|
||||
}
|
||||
|
||||
public string Content
|
||||
{
|
||||
get { return txtContent.Text; }
|
||||
set { txtContent.Text = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 1.3
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
@@ -14,16 +14,17 @@
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">1.3</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1">this is my long string</data>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
[base64 mime encoded serialized .NET Framework object]
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
@@ -35,7 +36,7 @@
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used forserialized objects, and tells the
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
@@ -45,7 +46,7 @@
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
@@ -59,18 +60,37 @@
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
@@ -89,21 +109,12 @@
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.Name">
|
||||
<value>OwnerDrawButton</value>
|
||||
</data>
|
||||
</root>
|
||||
8
vCardEditor/View/Customs/PanelType.cs
Normal file
8
vCardEditor/View/Customs/PanelType.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace vCardEditor.View.Customs
|
||||
{
|
||||
public enum PanelType
|
||||
{
|
||||
Phone,
|
||||
Web
|
||||
}
|
||||
}
|
||||
91
vCardEditor/View/Customs/RemovableTextBox.Designer.cs
generated
Normal file
91
vCardEditor/View/Customs/RemovableTextBox.Designer.cs
generated
Normal file
@@ -0,0 +1,91 @@
|
||||
|
||||
namespace vCardEditor.View.Customs
|
||||
{
|
||||
partial class RemovableTextBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Variable nécessaire au concepteur.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Nettoyage des ressources utilisées.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true si les ressources managées doivent être supprimées ; sinon, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Code généré par le Concepteur de composants
|
||||
|
||||
/// <summary>
|
||||
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
|
||||
/// le contenu de cette méthode avec l'éditeur de code.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.btnRemove = new System.Windows.Forms.Button();
|
||||
this.TitleLabel = new System.Windows.Forms.Label();
|
||||
this.ContentTextBox = new vCardEditor.View.StateTextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnRemove
|
||||
//
|
||||
this.btnRemove.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnRemove.BackgroundImage = global::vCardEditor.Properties.Resources.Close;
|
||||
this.btnRemove.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.btnRemove.FlatAppearance.BorderSize = 0;
|
||||
this.btnRemove.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnRemove.Location = new System.Drawing.Point(315, 4);
|
||||
this.btnRemove.Name = "btnRemove";
|
||||
this.btnRemove.Size = new System.Drawing.Size(18, 24);
|
||||
this.btnRemove.TabIndex = 13;
|
||||
this.btnRemove.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// TitleLabel
|
||||
//
|
||||
this.TitleLabel.Location = new System.Drawing.Point(-1, 6);
|
||||
this.TitleLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.TitleLabel.Name = "TitleLabel";
|
||||
this.TitleLabel.Size = new System.Drawing.Size(61, 23);
|
||||
this.TitleLabel.TabIndex = 11;
|
||||
this.TitleLabel.Text = "Home :";
|
||||
this.TitleLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// ContentTextBox
|
||||
//
|
||||
this.ContentTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ContentTextBox.Location = new System.Drawing.Point(67, 6);
|
||||
this.ContentTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.ContentTextBox.Name = "ContentTextBox";
|
||||
this.ContentTextBox.oldText = null;
|
||||
this.ContentTextBox.Size = new System.Drawing.Size(241, 22);
|
||||
this.ContentTextBox.TabIndex = 12;
|
||||
//
|
||||
// RemovableTextBox
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.btnRemove);
|
||||
this.Controls.Add(this.TitleLabel);
|
||||
this.Controls.Add(this.ContentTextBox);
|
||||
this.Name = "RemovableTextBox";
|
||||
this.Size = new System.Drawing.Size(332, 35);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btnRemove;
|
||||
internal System.Windows.Forms.Label TitleLabel;
|
||||
internal StateTextBox ContentTextBox;
|
||||
}
|
||||
}
|
||||
50
vCardEditor/View/Customs/RemovableTextBox.cs
Normal file
50
vCardEditor/View/Customs/RemovableTextBox.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using Thought.vCards;
|
||||
|
||||
namespace vCardEditor.View.Customs
|
||||
{
|
||||
public partial class RemovableTextBox : UserControl
|
||||
{
|
||||
public event EventHandler BoutonRemoveClicked;
|
||||
public event EventHandler ContentTextChanged;
|
||||
public RemovableTextBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
btnRemove.Click += (s, e) => BoutonRemoveClicked?.Invoke(s, e);
|
||||
// Bubble up to set the dirty flag from the parent.
|
||||
ContentTextBox.LostFocus += (s, e) => ContentTextChanged?.Invoke(s, e);
|
||||
ContentTextBox.Validated += (s, e) => ContentTextChanged?.Invoke(s, e);
|
||||
|
||||
//Reflect the changes inside the control, stored inside the Tag.
|
||||
ContentTextBox.Validated += ContentTextBox_Validated;
|
||||
}
|
||||
|
||||
private void ContentTextBox_Validated(object sender, EventArgs e)
|
||||
{
|
||||
var card = this.Tag as vCardRoot;
|
||||
card.ChangeContent(Content);
|
||||
}
|
||||
|
||||
public RemovableTextBox(vCardRoot cardType) : this()
|
||||
{
|
||||
this.Tag = cardType;
|
||||
Title = cardType.GetNameType();
|
||||
Content = cardType.ToString();
|
||||
}
|
||||
|
||||
|
||||
public string Title
|
||||
{
|
||||
get { return TitleLabel.Text; }
|
||||
set { TitleLabel.Text = value; }
|
||||
}
|
||||
|
||||
public string Content
|
||||
{
|
||||
get { return ContentTextBox.Text; }
|
||||
set { ContentTextBox.Text = value; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 1.3
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
@@ -14,16 +14,17 @@
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">1.3</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1">this is my long string</data>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
[base64 mime encoded serialized .NET Framework object]
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
@@ -35,7 +36,7 @@
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used forserialized objects, and tells the
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
@@ -45,7 +46,7 @@
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
@@ -59,18 +60,37 @@
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
@@ -89,21 +109,12 @@
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.Name">
|
||||
<value>ExpandingPanel</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1,34 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace VCFEditor.View
|
||||
{
|
||||
|
||||
//public class ArgumentEventArgs : EventArgs
|
||||
//{
|
||||
// public object argument { get; set; }
|
||||
//}
|
||||
|
||||
//http://stackoverflow.com/questions/3312134/does-net-have-a-built-in-eventargst
|
||||
|
||||
public class EventArg<T> : EventArgs
|
||||
{
|
||||
// Property variable
|
||||
private T p_EventData;
|
||||
|
||||
// Constructor
|
||||
public EventArg(T data)
|
||||
{
|
||||
p_EventData = data;
|
||||
Data = data;
|
||||
}
|
||||
|
||||
// Property for EventArgs argument
|
||||
public T Data
|
||||
{
|
||||
get { return p_EventData; }
|
||||
set { p_EventData = value;}
|
||||
}
|
||||
public T Data { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ namespace VCFEditor.View
|
||||
event EventHandler<EventArg<FormState>> LoadForm;
|
||||
event EventHandler AddContact;
|
||||
event EventHandler DeleteContact;
|
||||
event EventHandler BeforeOpeningNewFile;
|
||||
event EventHandler SaveContactsSelected;
|
||||
event EventHandler<EventArg<string>> NewFileOpened;
|
||||
event EventHandler ChangeContactsSelected;
|
||||
@@ -22,11 +21,12 @@ namespace VCFEditor.View
|
||||
event EventHandler<EventArg<bool>> CloseForm;
|
||||
event EventHandler<EventArg<string>> ModifyImage;
|
||||
event EventHandler ExportImage;
|
||||
event EventHandler ExportQR;
|
||||
event EventHandler<EventArg<List<vCardDeliveryAddressTypes>>> AddressAdded;
|
||||
event EventHandler<EventArg<List<vCardDeliveryAddressTypes>>> AddressModified;
|
||||
event EventHandler<EventArg<int>> AddressRemoved;
|
||||
event EventHandler CopyTextToClipboardEvent;
|
||||
|
||||
event EventHandler<EventArg<vCardPropeties>> AddExtraField;
|
||||
int SelectedContactIndex { get; }
|
||||
void DisplayContacts(SortableBindingList<Contact> contacts);
|
||||
void DisplayContactDetail(vCard card, string FileName);
|
||||
@@ -40,5 +40,8 @@ namespace VCFEditor.View
|
||||
void SendTextToClipBoard(string text);
|
||||
|
||||
FormState GetFormState();
|
||||
void LoadIntialState(FormState state);
|
||||
void AddExtraTextGroup(vCardPropeties type, string content);
|
||||
void DisplayQRCode(string content);
|
||||
}
|
||||
}
|
||||
|
||||
845
vCardEditor/View/MainForm.Designer.cs
generated
845
vCardEditor/View/MainForm.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -10,27 +10,29 @@ using vCardEditor.Model;
|
||||
using System.Drawing;
|
||||
using System.Collections.Generic;
|
||||
using vCardEditor.View.Customs;
|
||||
using vCardEditor.View.UIToolbox;
|
||||
|
||||
namespace vCardEditor.View
|
||||
{
|
||||
public partial class MainForm : Form, IMainView
|
||||
{
|
||||
public event EventHandler<EventArg<FormState>> LoadForm;
|
||||
public event EventHandler AddContact;
|
||||
public event EventHandler SaveContactsSelected;
|
||||
public event EventHandler BeforeOpeningNewFile;
|
||||
public event EventHandler DeleteContact;
|
||||
public event EventHandler<EventArg<string>> NewFileOpened;
|
||||
public event EventHandler ChangeContactsSelected;
|
||||
public event EventHandler<EventArg<vCard>> BeforeLeavingContact;
|
||||
public event EventHandler<EventArg<string>> FilterTextChanged;
|
||||
public event EventHandler TextBoxValueChanged;
|
||||
public event EventHandler<EventArg<bool>> CloseForm;
|
||||
public event EventHandler<EventArg<string>> ModifyImage;
|
||||
public event EventHandler<EventArg<List<vCardDeliveryAddressTypes>>> AddressAdded;
|
||||
public event EventHandler<EventArg<List<vCardDeliveryAddressTypes>>> AddressModified;
|
||||
public event EventHandler<EventArg<List<vCardDeliveryAddressTypes>>> AddressAdded;
|
||||
public event EventHandler<EventArg<string>> NewFileOpened;
|
||||
public event EventHandler<EventArg<string>> FilterTextChanged;
|
||||
public event EventHandler<EventArg<string>> ModifyImage;
|
||||
public event EventHandler<EventArg<bool>> CloseForm;
|
||||
public event EventHandler<EventArg<int>> AddressRemoved;
|
||||
public event EventHandler<EventArg<vCardPropeties>> AddExtraField;
|
||||
public event EventHandler SaveContactsSelected;
|
||||
public event EventHandler DeleteContact;
|
||||
public event EventHandler AddContact;
|
||||
public event EventHandler ChangeContactsSelected;
|
||||
public event EventHandler TextBoxValueChanged;
|
||||
public event EventHandler ExportImage;
|
||||
public event EventHandler ExportQR;
|
||||
public event EventHandler CopyTextToClipboardEvent;
|
||||
|
||||
ComponentResourceManager resources;
|
||||
@@ -50,15 +52,23 @@ namespace vCardEditor.View
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
this.extendedPanelWeb = new vCardEditor.View.Customs.ExtendedPanel(PanelType.Web);
|
||||
this.extendedPanelPhones = new vCardEditor.View.Customs.ExtendedPanel(PanelType.Phone);
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
resources = new ComponentResourceManager(typeof(MainForm));
|
||||
tbcAddress.AddTab += (sender, e) => AddressAdded?.Invoke(sender, e);
|
||||
tbcAddress.RemoveTab += (sender, e) => AddressRemoved?.Invoke(sender, e);
|
||||
tbcAddress.ModifyTab += (sender, e) => AddressModified?.Invoke(sender, e);
|
||||
tbcAddress.TextChangedEvent += (sender, e) => TextBoxValueChanged?.Invoke(sender, e);
|
||||
btnClearFilter.Click += (sender, e) => textBoxFilter.Clear();
|
||||
extendedPanelPhones.ContentTextChanged += (sender, e) => TextBoxValueChanged?.Invoke(sender, e);
|
||||
extendedPanelWeb.ContentTextChanged += (sender, e) => TextBoxValueChanged?.Invoke(sender, e);
|
||||
BuildMRUMenu();
|
||||
|
||||
}
|
||||
|
||||
private void tbsOpen_Click(object sender, EventArgs e)
|
||||
{
|
||||
NewFileOpened?.Invoke(sender, new EventArg<string>(string.Empty));
|
||||
@@ -77,6 +87,10 @@ namespace vCardEditor.View
|
||||
{
|
||||
//make sure the last changes in the textboxes is saved.
|
||||
Validate();
|
||||
|
||||
//Make sure to save changes for the current row.
|
||||
dgContacts_RowLeave(null, null);
|
||||
|
||||
SaveContactsSelected(sender, e);
|
||||
}
|
||||
|
||||
@@ -105,31 +119,90 @@ namespace vCardEditor.View
|
||||
|
||||
public void DisplayContactDetail(vCard card, string FileName)
|
||||
{
|
||||
if (card == null)
|
||||
throw new ArgumentException("card must be valid!");
|
||||
|
||||
if (card == null)
|
||||
throw new ArgumentException("vCard must be valid!");
|
||||
|
||||
ClearContactDetail();
|
||||
|
||||
Text = string.Format("{0} - vCard Editor", FileName);
|
||||
gbContactDetail.Enabled = true;
|
||||
//gbContactDetail.Enabled = true;
|
||||
tcMainTab.Enabled = true;
|
||||
gbNameList.Enabled = true;
|
||||
|
||||
SetSummaryValue(FormattedTitleValue, card.Title);
|
||||
SetSummaryValue(firstNameValue, card.GivenName);
|
||||
SetSummaryValue(lastNameValue, card.FamilyName);
|
||||
SetSummaryValue(middleNameValue, card.AdditionalNames);
|
||||
SetSummaryValue(FormattedTitleValue, card.Title);
|
||||
SetSummaryValue(FormattedNameValue, card.FormattedName);
|
||||
SetSummaryValue(HomePhoneValue, card.Phones.GetFirstChoice(vCardPhoneTypes.Home));
|
||||
SetSummaryValue(CellularPhoneValue, card.Phones.GetFirstChoice(vCardPhoneTypes.Cellular));
|
||||
SetSummaryValue(WorkPhoneValue, card.Phones.GetFirstChoice(vCardPhoneTypes.Work));
|
||||
SetSummaryValue(EmailAddressValue, card.EmailAddresses.GetFirstChoice(vCardEmailAddressType.Internet));
|
||||
SetSummaryValue(PersonalWebSiteValue, card.Websites.GetFirstChoice(vCardWebsiteTypes.Personal));
|
||||
|
||||
SetAddressesValues(card);
|
||||
SetPhotoValue(card.Photos);
|
||||
|
||||
SetExtraInfos(card);
|
||||
|
||||
SetExtraTabFields(card);
|
||||
|
||||
}
|
||||
|
||||
private void SetExtraInfos(vCard card)
|
||||
{
|
||||
foreach (var item in card.EmailAddresses)
|
||||
{
|
||||
extendedPanelWeb.AddControl(item);
|
||||
}
|
||||
|
||||
foreach (var item in card.Websites)
|
||||
{
|
||||
extendedPanelWeb.AddControl(item);
|
||||
}
|
||||
|
||||
foreach (var item in card.Phones)
|
||||
{
|
||||
extendedPanelPhones.AddControl(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void SetExtraTabFields(vCard card)
|
||||
{
|
||||
if (card.Notes.Count > 0)
|
||||
{
|
||||
foreach (var note in card.Notes)
|
||||
AddExtraTextGroup(vCardPropeties.NOTE, note.Text);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(card.Organization))
|
||||
{
|
||||
AddExtraTextGroup(vCardPropeties.ORG, card.Organization);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void AddExtraTextGroup(vCardPropeties type, string content)
|
||||
{
|
||||
ExtraTextGroup etg = new ExtraTextGroup();
|
||||
etg.Content = content;
|
||||
etg.Caption = type.ToString() + " :";
|
||||
etg.CardProp = type;
|
||||
etg.TextChangedEvent += (sender, e) => TextBoxValueChanged?.Invoke(sender, e);
|
||||
etg.ControlDeleted += (sender, e) =>
|
||||
{
|
||||
var send = sender as Control;
|
||||
panelTabExtra.Controls.Remove(send.Parent);
|
||||
};
|
||||
etg.Dock = DockStyle.Top;
|
||||
|
||||
|
||||
panelTabExtra.Controls.Add(etg);
|
||||
}
|
||||
|
||||
public void ClearContactDetail()
|
||||
{
|
||||
gbContactDetail.Enabled = false;
|
||||
//gbContactDetail.Enabled = false;
|
||||
tcMainTab.Enabled = false;
|
||||
gbNameList.Enabled = false;
|
||||
|
||||
SetSummaryValue(firstNameValue, string.Empty);
|
||||
@@ -137,14 +210,14 @@ namespace vCardEditor.View
|
||||
SetSummaryValue(middleNameValue, string.Empty);
|
||||
SetSummaryValue(FormattedTitleValue, string.Empty);
|
||||
SetSummaryValue(FormattedNameValue, string.Empty);
|
||||
SetSummaryValue(HomePhoneValue, string.Empty);
|
||||
SetSummaryValue(CellularPhoneValue, string.Empty);
|
||||
SetSummaryValue(WorkPhoneValue, string.Empty);
|
||||
SetSummaryValue(EmailAddressValue, string.Empty);
|
||||
SetSummaryValue(PersonalWebSiteValue, string.Empty);
|
||||
SetAddressesValues(new vCard());
|
||||
SetPhotoValue(new vCardPhotoCollection());
|
||||
|
||||
//SetAddressesValues(new vCard());
|
||||
|
||||
|
||||
SetPhotoValue(new vCardPhotoCollection());
|
||||
panelTabExtra.Controls.Clear();
|
||||
extendedPanelPhones.ClearFields();
|
||||
extendedPanelWeb.ClearFields();
|
||||
}
|
||||
|
||||
private void SetSummaryValue(StateTextBox valueLabel, string value)
|
||||
@@ -157,28 +230,6 @@ namespace vCardEditor.View
|
||||
valueLabel.oldText = value;
|
||||
}
|
||||
|
||||
private void SetSummaryValue(StateTextBox valueLabel, vCardEmailAddress email)
|
||||
{
|
||||
valueLabel.Text = string.Empty;
|
||||
if (email != null)
|
||||
SetSummaryValue(valueLabel, email.Address);
|
||||
}
|
||||
|
||||
private void SetSummaryValue(StateTextBox valueLabel, vCardPhone phone)
|
||||
{
|
||||
valueLabel.Text = string.Empty;
|
||||
if (phone != null)
|
||||
SetSummaryValue(valueLabel, phone.FullNumber);
|
||||
|
||||
}
|
||||
|
||||
private void SetSummaryValue(StateTextBox valueLabel, vCardWebsite webSite)
|
||||
{
|
||||
valueLabel.Text = string.Empty;
|
||||
if (webSite != null)
|
||||
SetSummaryValue(valueLabel, webSite.Url.ToString());
|
||||
}
|
||||
|
||||
void SetPhotoValue(vCardPhotoCollection photos)
|
||||
{
|
||||
if (photos.Any())
|
||||
@@ -231,11 +282,7 @@ namespace vCardEditor.View
|
||||
FilterTextChanged?.Invoke(sender, new EventArg<string>(textBoxFilter.Text));
|
||||
}
|
||||
|
||||
private void btnClearFilter_Click(object sender, EventArgs e)
|
||||
{
|
||||
textBoxFilter.Text = string.Empty;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private vCard GetvCardFromWindow()
|
||||
{
|
||||
@@ -250,23 +297,72 @@ namespace vCardEditor.View
|
||||
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(HomePhoneValue.Text))
|
||||
card.Phones.Add(new vCardPhone(HomePhoneValue.Text, vCardPhoneTypes.Home));
|
||||
if (!string.IsNullOrEmpty(CellularPhoneValue.Text))
|
||||
card.Phones.Add(new vCardPhone(CellularPhoneValue.Text, vCardPhoneTypes.Cellular));
|
||||
if (!string.IsNullOrEmpty(WorkPhoneValue.Text))
|
||||
card.Phones.Add(new vCardPhone(WorkPhoneValue.Text, vCardPhoneTypes.Work));
|
||||
if (!string.IsNullOrEmpty(this.EmailAddressValue.Text))
|
||||
card.EmailAddresses.Add(new vCardEmailAddress(this.EmailAddressValue.Text));
|
||||
if (!string.IsNullOrEmpty(this.PersonalWebSiteValue.Text))
|
||||
card.Websites.Add(new vCardWebsite(this.PersonalWebSiteValue.Text));
|
||||
|
||||
|
||||
tbcAddress.getDeliveryAddress(card);
|
||||
|
||||
getExtraPhones(card);
|
||||
getExtraWeb(card);
|
||||
getExtraData(card);
|
||||
return card;
|
||||
}
|
||||
|
||||
private void getExtraPhones(vCard card)
|
||||
{
|
||||
card.Phones.Clear();
|
||||
foreach (var item in extendedPanelPhones.GetExtraFields())
|
||||
{
|
||||
if (item is vCardPhone)
|
||||
{
|
||||
vCardPhone phone = item as vCardPhone;
|
||||
card.Phones.Add(phone);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void getExtraWeb(vCard card)
|
||||
{
|
||||
card.Websites.Clear();
|
||||
card.EmailAddresses.Clear();
|
||||
|
||||
foreach (var item in extendedPanelWeb.GetExtraFields())
|
||||
{
|
||||
switch (item)
|
||||
{
|
||||
case vCardEmailAddress email:
|
||||
card.EmailAddresses.Add(email);
|
||||
break;
|
||||
|
||||
case vCardWebsite website:
|
||||
card.Websites.Add(website);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void getExtraData(vCard card)
|
||||
{
|
||||
foreach (var item in panelTabExtra.Controls)
|
||||
{
|
||||
var tbc = item as ExtraTextGroup;
|
||||
switch (tbc.CardProp)
|
||||
{
|
||||
case vCardPropeties.NOTE:
|
||||
card.Notes.Add(tbc.Content);
|
||||
break;
|
||||
case vCardPropeties.ORG:
|
||||
card.Organization = tbc.Content;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dgContacts_RowLeave(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
vCard data = GetvCardFromWindow();
|
||||
@@ -365,8 +461,10 @@ namespace vCardEditor.View
|
||||
public string DisplaySaveDialog(string filename)
|
||||
{
|
||||
|
||||
var saveFileDialog = new SaveFileDialog();
|
||||
saveFileDialog.FileName = filename;
|
||||
var saveFileDialog = new SaveFileDialog
|
||||
{
|
||||
FileName = filename
|
||||
};
|
||||
|
||||
DialogResult result = saveFileDialog.ShowDialog();
|
||||
if (result == DialogResult.OK)
|
||||
@@ -502,20 +600,64 @@ namespace vCardEditor.View
|
||||
var evt = new EventArg<FormState>(new FormState());
|
||||
LoadForm?.Invoke(sender, evt);
|
||||
|
||||
//TODO: Better way to check if state was serialised!
|
||||
var state = evt.Data;
|
||||
}
|
||||
|
||||
public void LoadIntialState(FormState state)
|
||||
{
|
||||
if (state.Width != 0 && state.Height != 0)
|
||||
{
|
||||
Size = new Size(state.Width, state.Height);
|
||||
Location = new Point(state.X , state.Y);
|
||||
Location = new Point(state.X, state.Y);
|
||||
splitContainer1.SplitterDistance = state.splitterPosition;
|
||||
if (state.Columns != null)
|
||||
{
|
||||
ToggleOnlySelected(state.Columns);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
private void tbsQR_Click(object sender, EventArgs e)
|
||||
{
|
||||
ExportQR?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
public void DisplayQRCode(string content)
|
||||
{
|
||||
QRDialog qr = new QRDialog(content);
|
||||
qr.ShowDialog();
|
||||
}
|
||||
|
||||
|
||||
private void addNotesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var evt = new EventArg<vCardPropeties>(vCardPropeties.NOTE);
|
||||
AddExtraField?.Invoke(sender, evt);
|
||||
}
|
||||
|
||||
private void addOrgToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var evt = new EventArg<vCardPropeties>(vCardPropeties.ORG);
|
||||
AddExtraField?.Invoke(sender, evt);
|
||||
}
|
||||
|
||||
private void btnAddExtraText_Click(object sender, EventArgs e)
|
||||
{
|
||||
Button btnSender = (Button)sender;
|
||||
Point ptLowerLeft = new Point(0, btnSender.Height);
|
||||
ptLowerLeft = btnSender.PointToScreen(ptLowerLeft);
|
||||
menuExtraField.Show(ptLowerLeft);
|
||||
}
|
||||
|
||||
|
||||
private void miNote_Click(object sender, EventArgs e)
|
||||
{
|
||||
var evt = new EventArg<vCardPropeties>(vCardPropeties.NOTE);
|
||||
AddExtraField?.Invoke(sender, evt);
|
||||
}
|
||||
|
||||
private void miOrg_Click(object sender, EventArgs e)
|
||||
{
|
||||
var evt = new EventArg<vCardPropeties>(vCardPropeties.ORG);
|
||||
AddExtraField?.Invoke(sender, evt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,6 +252,41 @@
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>353, 17</value>
|
||||
</metadata>
|
||||
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="FormattedName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="FamilyName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Cellular.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="bsContacts.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>486, 17</value>
|
||||
</metadata>
|
||||
<data name="btnClearFilter.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vAAADrwBlbxySQAAAnhJREFUOE9tk19IU3EUx0+t1h/XxMo0QSj/9dRMSpv2RwI1epNEBIfln0BW+NCm
|
||||
S/tjapRk6rSodKtQWsPGIlLoYSDoQ8/lIOi5hwL3oNO5Pw75ds7dNZJ24MM593vO93Dv795L/8YY0WkH
|
||||
0YRkVfobrJ9gRl4RHVOlrTFO1DqhS8GPbhsky7XaEnP/h/wc+C03/uspsWleHB/GxvwMAs4RuDMPQYyC
|
||||
N/cIIjNubMxNI+Cwb12imFP2YvFZP+IeJ9ZfDyH+3oGw5w28eTkK4Skn4u6XWHcOKDOLo/0Qj5OoTp57
|
||||
4belFbHhHsTsvYgNdiM2dJ8XjWLt7ZiC1KIpPZnh+qf5qtzFPI0StXkz0rHSbka024pory1B3y1EH3Ql
|
||||
kFq0ng6esSiz4rETXZGn2DVI9NybfgAr5kZErNcRsbUlx2rGL1MNZFY87NXKgm3MnidEL9z7dAjU1yJs
|
||||
bklKwFSLCa0WfURd4lG97CQy8jrXbFEhwjYLQo0NCDXUb4W1cGc7Zg3HwfP8clSzfDR8GJPf62oRuXcH
|
||||
a9dasFpdnRTpRe7exuypk3KAk8oHJ4XfWIpQUxNWL9dgpfJigooqplKFa1UP1Zt4thn+sjPKEjkJ10Ju
|
||||
AYLGcwiWnkewrJzhbDyLhdw8BakVTXoyw9dzh7PwlKiDHhKVDxF9/JKRhWVDMZYLSziX4Fv2UTwi+ixI
|
||||
LVqiVwxf2kGwx1VBlCrHoDHxDzJANOXTp2Ep34Cvmdl4TDRtJbokSC3aUoEBPv1+8KybfXpmuyyQ0DCp
|
||||
0ni3Yyf4lX7qJKpSdY3Uonm0u5OaN0OElGaiIs4yIObNkFp/k+gCZx2jmon+AEJJs9KsJOQkAAAAAElF
|
||||
TkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>618, 17</value>
|
||||
</metadata>
|
||||
<data name="btnExportImage.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
|
||||
@@ -301,40 +336,8 @@
|
||||
XvxneHv7DU8zWBta5VGXAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<metadata name="bsContacts.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>486, 17</value>
|
||||
</metadata>
|
||||
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="FormattedName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="FamilyName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Cellular.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<data name="btnClearFilter.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vAAADrwBlbxySQAAAnhJREFUOE9tk19IU3EUx0+t1h/XxMo0QSj/9dRMSpv2RwI1epNEBIfln0BW+NCm
|
||||
S/tjapRk6rSodKtQWsPGIlLoYSDoQ8/lIOi5hwL3oNO5Pw75ds7dNZJ24MM593vO93Dv795L/8YY0WkH
|
||||
0YRkVfobrJ9gRl4RHVOlrTFO1DqhS8GPbhsky7XaEnP/h/wc+C03/uspsWleHB/GxvwMAs4RuDMPQYyC
|
||||
N/cIIjNubMxNI+Cwb12imFP2YvFZP+IeJ9ZfDyH+3oGw5w28eTkK4Skn4u6XWHcOKDOLo/0Qj5OoTp57
|
||||
4belFbHhHsTsvYgNdiM2dJ8XjWLt7ZiC1KIpPZnh+qf5qtzFPI0StXkz0rHSbka024pory1B3y1EH3Ql
|
||||
kFq0ng6esSiz4rETXZGn2DVI9NybfgAr5kZErNcRsbUlx2rGL1MNZFY87NXKgm3MnidEL9z7dAjU1yJs
|
||||
bklKwFSLCa0WfURd4lG97CQy8jrXbFEhwjYLQo0NCDXUb4W1cGc7Zg3HwfP8clSzfDR8GJPf62oRuXcH
|
||||
a9dasFpdnRTpRe7exuypk3KAk8oHJ4XfWIpQUxNWL9dgpfJigooqplKFa1UP1Zt4thn+sjPKEjkJ10Ju
|
||||
AYLGcwiWnkewrJzhbDyLhdw8BakVTXoyw9dzh7PwlKiDHhKVDxF9/JKRhWVDMZYLSziX4Fv2UTwi+ixI
|
||||
LVqiVwxf2kGwx1VBlCrHoDHxDzJANOXTp2Ep34Cvmdl4TDRtJbokSC3aUoEBPv1+8KybfXpmuyyQ0DCp
|
||||
0ni3Yyf4lX7qJKpSdY3Uonm0u5OaN0OElGaiIs4yIObNkFp/k+gCZx2jmon+AEJJs9KsJOQkAAAAAElF
|
||||
TkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>618, 17</value>
|
||||
<metadata name="menuExtraField.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>804, 17</value>
|
||||
</metadata>
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
||||
94
vCardEditor/View/QRDialog.Designer.cs
generated
Normal file
94
vCardEditor/View/QRDialog.Designer.cs
generated
Normal file
@@ -0,0 +1,94 @@
|
||||
|
||||
namespace vCardEditor.View
|
||||
{
|
||||
partial class QRDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.btnExport = new System.Windows.Forms.Button();
|
||||
this.btnClose = new System.Windows.Forms.Button();
|
||||
this.pictureBoxQRCode = new System.Windows.Forms.PictureBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxQRCode)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnExport
|
||||
//
|
||||
this.btnExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnExport.Location = new System.Drawing.Point(464, 385);
|
||||
this.btnExport.Name = "btnExport";
|
||||
this.btnExport.Size = new System.Drawing.Size(75, 28);
|
||||
this.btnExport.TabIndex = 5;
|
||||
this.btnExport.Text = "Export..";
|
||||
this.btnExport.UseVisualStyleBackColor = true;
|
||||
this.btnExport.Click += new System.EventHandler(this.btnExport_Click);
|
||||
//
|
||||
// btnClose
|
||||
//
|
||||
this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnClose.Location = new System.Drawing.Point(550, 386);
|
||||
this.btnClose.Name = "btnClose";
|
||||
this.btnClose.Size = new System.Drawing.Size(75, 28);
|
||||
this.btnClose.TabIndex = 4;
|
||||
this.btnClose.Text = "Close";
|
||||
this.btnClose.UseVisualStyleBackColor = true;
|
||||
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
|
||||
//
|
||||
// pictureBoxQRCode
|
||||
//
|
||||
this.pictureBoxQRCode.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pictureBoxQRCode.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.pictureBoxQRCode.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.pictureBoxQRCode.Location = new System.Drawing.Point(12, 12);
|
||||
this.pictureBoxQRCode.Name = "pictureBoxQRCode";
|
||||
this.pictureBoxQRCode.Size = new System.Drawing.Size(613, 367);
|
||||
this.pictureBoxQRCode.TabIndex = 3;
|
||||
this.pictureBoxQRCode.TabStop = false;
|
||||
//
|
||||
// QRDialog
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(640, 422);
|
||||
this.Controls.Add(this.btnExport);
|
||||
this.Controls.Add(this.btnClose);
|
||||
this.Controls.Add(this.pictureBoxQRCode);
|
||||
this.Name = "QRDialog";
|
||||
this.Text = "QR Generator";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxQRCode)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btnExport;
|
||||
private System.Windows.Forms.Button btnClose;
|
||||
private System.Windows.Forms.PictureBox pictureBoxQRCode;
|
||||
}
|
||||
}
|
||||
93
vCardEditor/View/QRDialog.cs
Normal file
93
vCardEditor/View/QRDialog.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using QRCoder;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace vCardEditor.View
|
||||
{
|
||||
public partial class QRDialog : Form
|
||||
{
|
||||
string _qrContentCode = null;
|
||||
public QRDialog(string content)
|
||||
{
|
||||
InitializeComponent();
|
||||
RenderQrCode(content);
|
||||
}
|
||||
|
||||
public void RenderQrCode(string code)
|
||||
{
|
||||
//TODO Change ECCLevel
|
||||
QRCodeGenerator.ECCLevel eccLevel = 0;
|
||||
|
||||
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
|
||||
using (QRCodeData qrCodeData = qrGenerator.CreateQrCode(code, eccLevel))
|
||||
using (QRCode qrCode = new QRCode(qrCodeData))
|
||||
{
|
||||
_qrContentCode = code;
|
||||
pictureBoxQRCode.BackgroundImage = qrCode.GetGraphic(20, Color.Black, Color.White, null, 1);
|
||||
pictureBoxQRCode.Size = new Size(pictureBoxQRCode.Width, pictureBoxQRCode.Height);
|
||||
pictureBoxQRCode.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void btnClose_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void btnExport_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Displays a SaveFileDialog so the user can save the Image
|
||||
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
|
||||
saveFileDialog1.Filter = "Bitmap Image|*.bmp|PNG Image|*.png|JPeg Image|*.jpg|Gif Image|*.gif|SVG Image|*.svg";
|
||||
saveFileDialog1.Title = "Save an Image File";
|
||||
saveFileDialog1.ShowDialog();
|
||||
|
||||
if (saveFileDialog1.FileName != "")
|
||||
{
|
||||
|
||||
if (saveFileDialog1.FilterIndex == 5)
|
||||
{
|
||||
QRCodeGenerator qrGenerator = new QRCodeGenerator();
|
||||
QRCodeData qrCodeData = qrGenerator.CreateQrCode(_qrContentCode, QRCodeGenerator.ECCLevel.H);
|
||||
SvgQRCode qrCode = new SvgQRCode(qrCodeData);
|
||||
string qrCodeAsSvg = qrCode.GetGraphic(20);
|
||||
|
||||
File.WriteAllText(saveFileDialog1.FileName, qrCodeAsSvg);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile())
|
||||
{
|
||||
|
||||
|
||||
ImageFormat imageFormat = null;
|
||||
switch (saveFileDialog1.FilterIndex)
|
||||
{
|
||||
case 1:
|
||||
imageFormat = ImageFormat.Bmp;
|
||||
break;
|
||||
case 2:
|
||||
imageFormat = ImageFormat.Png;
|
||||
break;
|
||||
case 3:
|
||||
imageFormat = ImageFormat.Jpeg;
|
||||
break;
|
||||
case 4:
|
||||
imageFormat = ImageFormat.Gif;
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("File extension is not supported");
|
||||
}
|
||||
pictureBoxQRCode.BackgroundImage.Save(fs, imageFormat);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
vCardEditor/View/QRDialog.resx
Normal file
120
vCardEditor/View/QRDialog.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -9,8 +9,8 @@ namespace vCardEditor.View
|
||||
|
||||
protected override void OnLostFocus(EventArgs e)
|
||||
{
|
||||
base.OnLostFocus(e);
|
||||
oldText = this.Text;
|
||||
base.OnLostFocus(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace UIToolbox
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for CollapseBox.
|
||||
/// </summary>
|
||||
public class CollapseBox : OwnerDrawButton
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.Container components = null;
|
||||
|
||||
#region Internal variables
|
||||
private bool m_bIsPlus;
|
||||
#endregion Internal variables
|
||||
|
||||
public CollapseBox()
|
||||
{
|
||||
// This call is required by the Windows.Forms Form Designer.
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if(components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
//
|
||||
// CollapseBox
|
||||
//
|
||||
this.Click += new System.EventHandler(this.CollapseBox_Click);
|
||||
this.Paint += new System.Windows.Forms.PaintEventHandler(this.CollapseBox_Paint);
|
||||
this.DoubleClick += new System.EventHandler(this.CollapseBox_DoubleClick);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
private void CollapseBox_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
IsPlus = !IsPlus;
|
||||
}
|
||||
|
||||
private void CollapseBox_DoubleClick(object sender, System.EventArgs e)
|
||||
{
|
||||
// fast clicking registers as double-clicking, so map a double-click
|
||||
// event into a single click.
|
||||
CollapseBox_Click(sender, e);
|
||||
}
|
||||
|
||||
private void CollapseBox_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
if(m_ButtonState == ButtonState.TrackingInside)
|
||||
g.FillRectangle(Brushes.LightGray, ClientRectangle);
|
||||
else
|
||||
g.FillRectangle(Brushes.White, ClientRectangle);
|
||||
|
||||
Rectangle theRec = new Rectangle();
|
||||
theRec = ClientRectangle;
|
||||
theRec.Width--;
|
||||
theRec.Height--;
|
||||
g.DrawRectangle(Pens.Black, theRec);
|
||||
g.DrawLine(Pens.Black, theRec.X + 2, theRec.Y + (this.Height/2),
|
||||
theRec.X + this.Width - 3, theRec.Y + (this.Height/2));
|
||||
if(m_bIsPlus)
|
||||
{
|
||||
g.DrawLine(Pens.Black, theRec.X + (this.Width/2), theRec.Y + 2,
|
||||
theRec.X + (this.Width/2), theRec.Y + this.Height - 3);
|
||||
}
|
||||
}
|
||||
#endregion Events
|
||||
|
||||
#region Accessors
|
||||
[DefaultValue(false)]
|
||||
public bool IsPlus
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bIsPlus;
|
||||
}
|
||||
set
|
||||
{
|
||||
if(m_bIsPlus != value)
|
||||
{
|
||||
m_bIsPlus = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion Accessors
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 824 B |
@@ -1,326 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace UIToolbox
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for CollapsibleGroupBox.
|
||||
/// </summary>
|
||||
public class CollapsibleGroupBox : System.Windows.Forms.UserControl
|
||||
{
|
||||
public const int kCollapsedHeight = 20;
|
||||
#region Members
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.Container components = null;
|
||||
|
||||
private CollapseBox m_CollapseBox;
|
||||
private ImageButton m_TrashIcon;
|
||||
public event CollapseBoxClickedEventHandler CollapseBoxClickedEvent;
|
||||
public event TrashCanClickedEventHandler TrashCanClickedEvent;
|
||||
|
||||
private string m_Caption;
|
||||
//private bool m_bContainsTrashCan;
|
||||
//private System.Windows.Forms.GroupBox m_GroupBox;
|
||||
private Size m_FullSize;
|
||||
private bool m_bResizingFromCollapse = false;
|
||||
#endregion Members
|
||||
|
||||
|
||||
public CollapsibleGroupBox()
|
||||
{
|
||||
// This call is required by the Windows.Forms Form Designer.
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if(components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(CollapsibleGroupBox));
|
||||
this.m_CollapseBox = new UIToolbox.CollapseBox();
|
||||
this.m_TrashIcon = new UIToolbox.ImageButton();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// m_CollapseBox
|
||||
//
|
||||
this.m_CollapseBox.IsPlus = false;
|
||||
this.m_CollapseBox.Location = new System.Drawing.Point(12, 1);
|
||||
this.m_CollapseBox.Name = "m_CollapseBox";
|
||||
this.m_CollapseBox.Size = new System.Drawing.Size(11, 11);
|
||||
this.m_CollapseBox.TabIndex = 1;
|
||||
this.m_CollapseBox.Click += new System.EventHandler(this.CollapseBox_Click);
|
||||
this.m_CollapseBox.DoubleClick += new System.EventHandler(this.CollapseBox_DoubleClick);
|
||||
//
|
||||
// m_TrashIcon
|
||||
//
|
||||
this.m_TrashIcon.Location = new System.Drawing.Point(88, 0);
|
||||
this.m_TrashIcon.Name = "m_TrashIcon";
|
||||
this.m_TrashIcon.NormalImage = ((System.Drawing.Image)(resources.GetObject("m_TrashIcon.NormalImage")));
|
||||
this.m_TrashIcon.PressedImage = ((System.Drawing.Image)(resources.GetObject("m_TrashIcon.PressedImage")));
|
||||
this.m_TrashIcon.Size = new System.Drawing.Size(16, 16);
|
||||
this.m_TrashIcon.TabIndex = 2;
|
||||
this.m_TrashIcon.TabStop = false;
|
||||
this.m_TrashIcon.Click += new System.EventHandler(this.TrashIcon_Click);
|
||||
//
|
||||
// CollapsibleGroupBox
|
||||
//
|
||||
this.Controls.Add(this.m_TrashIcon);
|
||||
this.Controls.Add(this.m_CollapseBox);
|
||||
this.Name = "CollapsibleGroupBox";
|
||||
this.Resize += new System.EventHandler(this.CollapsibleGroupBox_Resize);
|
||||
this.Load += new System.EventHandler(this.CollapsibleGroupBox_Load);
|
||||
this.Paint += new System.Windows.Forms.PaintEventHandler(this.CollapsibleGroupBox_Paint);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
private void CollapsibleGroupBox_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
SetGroupBoxCaption();
|
||||
}
|
||||
|
||||
private void CollapsibleGroupBox_Resize(object sender, System.EventArgs e)
|
||||
{
|
||||
if(m_bResizingFromCollapse != true)
|
||||
{
|
||||
m_FullSize = this.Size;
|
||||
}
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
private void CollapsibleGroupBox_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
|
||||
{
|
||||
// UG! I originall added a GroupBox control but ran into problems...
|
||||
// Panes derived from CollapsibleGroupBox would "chew up" controls
|
||||
// added to them, so I had to get rid of the GroupBox and draw a fake
|
||||
// group box myself
|
||||
Graphics g = e.Graphics;
|
||||
Rectangle theRec = new Rectangle();
|
||||
theRec = this.ClientRectangle;
|
||||
|
||||
//Color theEdgeGrayColor = Color.FromArgb(170, 170, 156);
|
||||
//Pen thePen = new Pen(theEdgeGrayColor);
|
||||
Pen thePen = SystemPens.ControlDark;
|
||||
|
||||
|
||||
int theTextSize = (int)g.MeasureString(m_Caption, this.Font).Width;
|
||||
if(theTextSize < 1)
|
||||
theTextSize = 1;
|
||||
|
||||
int theCaptionPosition = (theRec.X + 8) + 2 + m_CollapseBox.Width + 2;
|
||||
int theEndPosition = theCaptionPosition + theTextSize + 1;
|
||||
if(m_TrashIcon.Visible)
|
||||
theEndPosition += (m_TrashIcon.Width + 2);
|
||||
|
||||
|
||||
g.DrawLine(thePen, theRec.X + 8, theRec.Y + 5,
|
||||
theRec.X, theRec.Y + 5);
|
||||
|
||||
g.DrawLine(thePen, theRec.X, theRec.Y + 5,
|
||||
theRec.X, theRec.Bottom - 2);
|
||||
|
||||
g.DrawLine(thePen, theRec.X, theRec.Bottom - 2,
|
||||
theRec.Right - 1, theRec.Bottom - 2);
|
||||
|
||||
g.DrawLine(thePen, theRec.Right - 2, theRec.Bottom - 2,
|
||||
theRec.Right - 2, theRec.Y + 5);
|
||||
|
||||
g.DrawLine(thePen, theRec.Right - 2, theRec.Y + 5,
|
||||
theRec.X + theEndPosition, theRec.Y + 5);
|
||||
|
||||
|
||||
|
||||
g.DrawLine(Pens.White, theRec.X + 8, theRec.Y + 6,
|
||||
theRec.X + 1, theRec.Y + 6);
|
||||
|
||||
g.DrawLine(Pens.White, theRec.X + 1, theRec.Y + 6,
|
||||
theRec.X + 1, theRec.Bottom - 3);
|
||||
|
||||
g.DrawLine(Pens.White, theRec.X, theRec.Bottom - 1,
|
||||
theRec.Right, theRec.Bottom - 1);
|
||||
|
||||
g.DrawLine(Pens.White, theRec.Right - 1, theRec.Bottom - 1,
|
||||
theRec.Right - 1, theRec.Y + 5);
|
||||
|
||||
g.DrawLine(Pens.White, theRec.Right - 3, theRec.Y + 6,
|
||||
theRec.X + theEndPosition, theRec.Y + 6);
|
||||
|
||||
StringFormat sf = new StringFormat();
|
||||
SolidBrush drawBrush = new SolidBrush(Color.Black);
|
||||
|
||||
g.DrawString(m_Caption, this.Font, drawBrush, theCaptionPosition, 0);
|
||||
}
|
||||
|
||||
public void CollapseBox_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
// at this point the control's value has changed but hasn't been
|
||||
// redrawn on the screen
|
||||
this.IsCollapsed = m_CollapseBox.IsPlus;
|
||||
|
||||
if(CollapseBoxClickedEvent != null)
|
||||
{
|
||||
CollapseBoxClickedEvent(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void CollapseBox_DoubleClick(object sender, System.EventArgs e)
|
||||
{
|
||||
// fast clicking registers as double-clicking, so map a double-click
|
||||
// event into a single click.
|
||||
CollapseBox_Click(sender, e);
|
||||
}
|
||||
|
||||
private void TrashIcon_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
if(TrashCanClickedEvent != null)
|
||||
{
|
||||
TrashCanClickedEvent(this);
|
||||
}
|
||||
}
|
||||
#endregion events
|
||||
|
||||
#region Accessors
|
||||
[DefaultValue("")]
|
||||
public string Caption
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Caption;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Caption = value;
|
||||
SetGroupBoxCaption();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(true)]
|
||||
public bool ContainsTrashCan
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_TrashIcon.Visible;
|
||||
}
|
||||
set
|
||||
{
|
||||
//m_bContainsTrashCan = value;
|
||||
m_TrashIcon.Visible = value;
|
||||
SetGroupBoxCaption();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public int FullHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_FullSize.Height;
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(false), Browsable(false)]
|
||||
public bool IsCollapsed
|
||||
{
|
||||
get
|
||||
{
|
||||
#if DEBUG
|
||||
if(m_CollapseBox.IsPlus)
|
||||
{
|
||||
Debug.Assert(this.Height == kCollapsedHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Assert(this.Height > kCollapsedHeight);
|
||||
}
|
||||
#endif
|
||||
return m_CollapseBox.IsPlus;
|
||||
}
|
||||
set
|
||||
{
|
||||
if(m_CollapseBox.IsPlus != value)
|
||||
{
|
||||
m_CollapseBox.IsPlus = value;
|
||||
}
|
||||
|
||||
if(m_CollapseBox.IsPlus != true)
|
||||
{
|
||||
//Expand();
|
||||
this.Size = m_FullSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Collapse();
|
||||
m_bResizingFromCollapse = true;
|
||||
Size smallSize = m_FullSize;
|
||||
smallSize.Height = kCollapsedHeight;
|
||||
this.Size = smallSize;
|
||||
m_bResizingFromCollapse = false;
|
||||
}
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
#endregion accessors
|
||||
|
||||
#region Methods
|
||||
private void SetGroupBoxCaption()
|
||||
{
|
||||
RepositionTrashCan();
|
||||
}
|
||||
|
||||
private void RepositionTrashCan()
|
||||
{
|
||||
if(m_TrashIcon.Visible)
|
||||
{
|
||||
// Since the trash icon's location is a function of the caption's width,
|
||||
// we also need to reposition the trash icon
|
||||
// first, find the width of the string
|
||||
Graphics g = CreateGraphics();
|
||||
SizeF theTextSize = new SizeF();
|
||||
theTextSize = g.MeasureString(m_Caption, this.Font);
|
||||
// Hmm... MeasureString() doesn't seem to be returning the
|
||||
// correct width. Close... but not exact
|
||||
|
||||
// 11 is the number of pixels from the beginning of the group box
|
||||
// to the beginning of text of the group box's caption
|
||||
//m_TrashIcon.Left = m_GroupBox.Location.X + 29 + (int)theTextSize.Width - 4;
|
||||
m_TrashIcon.Left = this.Location.X + 29 + (int)theTextSize.Width - 4;
|
||||
// -4 is a fudge factor. Hey, what can I say...
|
||||
}
|
||||
}
|
||||
#endregion Methods
|
||||
|
||||
|
||||
public delegate void CollapseBoxClickedEventHandler(object sender);
|
||||
public delegate void TrashCanClickedEventHandler(object sender);
|
||||
}
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 1.3
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">1.3</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1">this is my long string</data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
[base64 mime encoded serialized .NET Framework object]
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used forserialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="m_CollapseBox.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="m_CollapseBox.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="m_CollapseBox.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="m_TrashIcon.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="m_TrashIcon.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="m_TrashIcon.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="m_TrashIcon.NormalImage" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAJdJREFUOE+VkgEK
|
||||
wDAIA9ef92n9WYdlEbVR2aB0OM3O6Hj4s0l4JLkuLIV7rXUdiX8n1XFFpkDjlYj785xzyxES+25FGQYQ
|
||||
uxaYP0ePoaqofBeaygdNgInAx90ZeQhCn/8IIIAbyPHO5ugmAU9IcWriZaTtvTMQVOqD3YEwgZ7A4ict
|
||||
pOOkG2nw45Son+Uou3WOipXYyX0Bl4EdsYyOw8oAAAAASUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<data name="m_TrashIcon.PressedImage" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAJhJREFUOE+VkgEK
|
||||
wDAIA9dP9gn9/w86LIuojcoGpcNpdkbHw59NwiPJdWEp3Gut60j8O6mOKzIFGq9E3J/nnFuOkNh3K8ow
|
||||
gNi1wPw5egxVReW70FQ+aAJMBD7uzshDEPr8RwAB3ECOdzZHNwl4QopTEy8jbe+dgaBSH+wOhAn0BBY/
|
||||
aSEdJ91Igx+nRP0sR9mtc1SsxE7uC3D26NQxC7BSAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="$this.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="$this.TrayHeight" type="System.Int32, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>80</value>
|
||||
</data>
|
||||
<data name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>(Default)</value>
|
||||
</data>
|
||||
<data name="$this.Localizable" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="$this.Name">
|
||||
<value>CollapsibleGroupBox</value>
|
||||
</data>
|
||||
<data name="$this.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>8, 8</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1,194 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace UIToolbox
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for ExpandingPanel.
|
||||
/// </summary>
|
||||
public class ExpandingPanel : System.Windows.Forms.Panel
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.Container components = null;
|
||||
ArrayList m_GroupArray = null;
|
||||
|
||||
|
||||
public const int kGap = 6;
|
||||
public ExpandingPanel()
|
||||
{
|
||||
// This call is required by the Windows.Forms Form Designer.
|
||||
InitializeComponent();
|
||||
|
||||
m_GroupArray = new ArrayList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if(components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
//
|
||||
// ExpandingPanel
|
||||
//
|
||||
this.Move += new System.EventHandler(this.ExpandingPanel_Move);
|
||||
this.Resize += new System.EventHandler(this.ExpandingPanel_Resize);
|
||||
this.SizeChanged += new System.EventHandler(this.ExpandingPanel_SizeChanged);
|
||||
this.Layout += new System.Windows.Forms.LayoutEventHandler(this.ExpandingPanel_Layout);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
public void AddGroup(UIToolbox.CollapsibleGroupBox theGroupBox)
|
||||
{
|
||||
m_GroupArray.Add(theGroupBox);
|
||||
|
||||
|
||||
this.SuspendLayout();
|
||||
Size theSize = this.AutoScrollMinSize;
|
||||
theGroupBox.Location = new System.Drawing.Point(4, theSize.Height + 4);
|
||||
|
||||
|
||||
theSize.Height += (theGroupBox.Height + kGap);
|
||||
this.AutoScrollMinSize = theSize;
|
||||
theGroupBox.CollapseBoxClickedEvent += new CollapsibleGroupBox.CollapseBoxClickedEventHandler(this.CollapseBox_Click);
|
||||
theGroupBox.TrashCanClickedEvent += new CollapsibleGroupBox.TrashCanClickedEventHandler(this.TrashCan_Click);
|
||||
this.Controls.Add(theGroupBox);
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
|
||||
private void ExpandingPanel_Layout(object sender, System.Windows.Forms.LayoutEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void ExpandingPanel_Move(object sender, System.EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void ExpandingPanel_Resize(object sender, System.EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void ExpandingPanel_SizeChanged(object sender, System.EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void CollapseBox_Click(object sender)
|
||||
{
|
||||
int nIndex;
|
||||
nIndex = m_GroupArray.IndexOf(sender);
|
||||
|
||||
CollapsibleGroupBox theGroupBox;
|
||||
theGroupBox = (CollapsibleGroupBox)m_GroupArray[nIndex];
|
||||
|
||||
int nDelta;
|
||||
if(theGroupBox.Height == CollapsibleGroupBox.kCollapsedHeight)
|
||||
{
|
||||
nDelta = -(theGroupBox.FullHeight - CollapsibleGroupBox.kCollapsedHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
nDelta = (theGroupBox.FullHeight - CollapsibleGroupBox.kCollapsedHeight);
|
||||
}
|
||||
|
||||
for(int i=(nIndex + 1); i<m_GroupArray.Count; i++)
|
||||
{
|
||||
theGroupBox = (CollapsibleGroupBox)m_GroupArray[i];
|
||||
theGroupBox.Top += nDelta;
|
||||
}
|
||||
|
||||
Size theSize = this.AutoScrollMinSize;
|
||||
theSize.Height += nDelta;
|
||||
this.AutoScrollMinSize = theSize;
|
||||
}
|
||||
|
||||
private void TrashCan_Click(object sender)
|
||||
{
|
||||
int nIndex;
|
||||
nIndex = m_GroupArray.IndexOf(sender);
|
||||
|
||||
CollapsibleGroupBox theGroupBox;
|
||||
theGroupBox = (CollapsibleGroupBox)m_GroupArray[nIndex];
|
||||
|
||||
int nDelta;
|
||||
nDelta = theGroupBox.Height + kGap;
|
||||
|
||||
m_GroupArray.RemoveAt(nIndex);
|
||||
theGroupBox.Dispose();
|
||||
theGroupBox = null;
|
||||
|
||||
for(int i=nIndex; i<m_GroupArray.Count; i++)
|
||||
{
|
||||
theGroupBox = (CollapsibleGroupBox)m_GroupArray[i];
|
||||
theGroupBox.Top -= nDelta;
|
||||
}
|
||||
|
||||
Size theSize = this.AutoScrollMinSize;
|
||||
theSize.Height -= nDelta;
|
||||
this.AutoScrollMinSize = theSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region NOT USED
|
||||
class IndexerArray
|
||||
{
|
||||
protected ArrayList data = new ArrayList();
|
||||
|
||||
public object this[int idx]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (idx > -1 && idx < data.Count)
|
||||
{
|
||||
return (data[idx]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("[IndexerArray.get_Item]Index out of range");
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (idx > -1 && idx < data.Count)
|
||||
{
|
||||
data[idx] = value;
|
||||
}
|
||||
else if (idx == data.Count)
|
||||
{
|
||||
data.Add(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("[IndexerArray.set_Item]Index out of range");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion NOT USED
|
||||
@@ -1,110 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace UIToolbox
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for ImageButton.
|
||||
/// </summary>
|
||||
public class ImageButton : OwnerDrawButton
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.Container components = null;
|
||||
|
||||
#region Internal variables
|
||||
private Image m_NormalImage = null;
|
||||
private Image m_PressedImage = null;
|
||||
#endregion Internal variables
|
||||
|
||||
public ImageButton()
|
||||
{
|
||||
// This call is required by the Windows.Forms Form Designer.
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if(components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
//
|
||||
// ImageButton
|
||||
//
|
||||
this.Paint += new System.Windows.Forms.PaintEventHandler(this.ImageButton_Paint);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
private void ImageButton_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
if(m_ButtonState == ButtonState.TrackingInside)
|
||||
{
|
||||
if(m_PressedImage != null)
|
||||
{
|
||||
g.DrawImage(m_PressedImage, 0, 0, m_PressedImage.Width, m_PressedImage.Height);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_NormalImage != null)
|
||||
{
|
||||
g.DrawImage(m_NormalImage, 0, 0, m_NormalImage.Width, m_NormalImage.Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion Events
|
||||
|
||||
#region Accessors
|
||||
public Image NormalImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_NormalImage;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_NormalImage = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public Image PressedImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_PressedImage;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_PressedImage = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
#endregion Accessors
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="ResMimeType">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="Version">
|
||||
<value>1.0.0.0</value>
|
||||
</resheader>
|
||||
<resheader name="Reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="Writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -1,136 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace UIToolbox
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for OwnerDrawButton.
|
||||
/// </summary>
|
||||
public class OwnerDrawButton : System.Windows.Forms.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.Container components = null;
|
||||
|
||||
#region Internal variables
|
||||
public enum ButtonState
|
||||
{
|
||||
Normal,
|
||||
TrackingInside,
|
||||
TrackingOutside
|
||||
}
|
||||
|
||||
protected ButtonState m_ButtonState = ButtonState.Normal;
|
||||
#endregion Internal variables
|
||||
|
||||
public OwnerDrawButton()
|
||||
{
|
||||
// This call is required by the Windows.Forms Form Designer.
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if(components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
//
|
||||
// OwnerDrawButton
|
||||
//
|
||||
this.Resize += new System.EventHandler(this.OwnerDrawButton_Resize);
|
||||
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OwnerDrawButton_MouseUp);
|
||||
this.Paint += new System.Windows.Forms.PaintEventHandler(this.OwnerDrawButton_Paint);
|
||||
this.MouseEnter += new System.EventHandler(this.OwnerDrawButton_MouseEnter);
|
||||
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OwnerDrawButton_MouseMove);
|
||||
this.MouseLeave += new System.EventHandler(this.OwnerDrawButton_MouseLeave);
|
||||
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OwnerDrawButton_MouseDown);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
private void OwnerDrawButton_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
|
||||
{
|
||||
// needs to be implemented by the derived class
|
||||
}
|
||||
|
||||
private void OwnerDrawButton_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
m_ButtonState = ButtonState.TrackingInside;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
private void OwnerDrawButton_MouseEnter(object sender, System.EventArgs e)
|
||||
{
|
||||
if(m_ButtonState == ButtonState.TrackingOutside)
|
||||
{
|
||||
m_ButtonState = ButtonState.TrackingInside;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void OwnerDrawButton_MouseLeave(object sender, System.EventArgs e)
|
||||
{
|
||||
if(m_ButtonState == ButtonState.TrackingInside)
|
||||
{
|
||||
m_ButtonState = ButtonState.TrackingOutside;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void OwnerDrawButton_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
if(m_ButtonState == ButtonState.Normal)
|
||||
return;
|
||||
|
||||
Rectangle bounds = new Rectangle(0, 0, this.Width, this.Height);
|
||||
if(m_ButtonState == ButtonState.TrackingInside)
|
||||
{
|
||||
if( !bounds.Contains(e.X, e.Y) )
|
||||
OwnerDrawButton_MouseLeave(sender, e);
|
||||
}
|
||||
else if(m_ButtonState == ButtonState.TrackingOutside)
|
||||
{
|
||||
if( bounds.Contains(e.X, e.Y) )
|
||||
OwnerDrawButton_MouseEnter(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void OwnerDrawButton_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
if(m_ButtonState != ButtonState.Normal)
|
||||
{
|
||||
m_ButtonState = ButtonState.Normal;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void OwnerDrawButton_Resize(object sender, System.EventArgs e)
|
||||
{
|
||||
Invalidate();
|
||||
}
|
||||
#endregion Events
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -66,6 +66,24 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Libs\QRCoder\AbstractQRCode.cs" />
|
||||
<Compile Include="Libs\QRCoder\ArtQRCode.cs" />
|
||||
<Compile Include="Libs\QRCoder\ASCIIQRCode.cs" />
|
||||
<Compile Include="Libs\QRCoder\Base64QRCode.cs" />
|
||||
<Compile Include="Libs\QRCoder\BitmapByteQRCode.cs" />
|
||||
<Compile Include="Libs\QRCoder\Exceptions\DataTooLongException.cs" />
|
||||
<Compile Include="Libs\QRCoder\Extensions\StringValueAttribute.cs" />
|
||||
<Compile Include="Libs\QRCoder\Framework4.0Methods\Stream4Methods.cs" />
|
||||
<Compile Include="Libs\QRCoder\Framework4.0Methods\String4Methods.cs" />
|
||||
<Compile Include="Libs\QRCoder\PayloadGenerator.cs" />
|
||||
<Compile Include="Libs\QRCoder\PdfByteQRCode.cs" />
|
||||
<Compile Include="Libs\QRCoder\PngByteQRCode.cs" />
|
||||
<Compile Include="Libs\QRCoder\PostscriptQRCode.cs" />
|
||||
<Compile Include="Libs\QRCoder\QRCode.cs" />
|
||||
<Compile Include="Libs\QRCoder\QRCodeData.cs" />
|
||||
<Compile Include="Libs\QRCoder\QRCodeGenerator.cs" />
|
||||
<Compile Include="Libs\QRCoder\SvgQRCode.cs" />
|
||||
<Compile Include="Model\vCardPropeties.cs" />
|
||||
<Compile Include="Model\Column.cs" />
|
||||
<Compile Include="Model\FixedList.cs" />
|
||||
<Compile Include="Model\ObjectCopier.cs" />
|
||||
@@ -110,6 +128,7 @@
|
||||
<Compile Include="Thought.vCards\vCardProperty.cs" />
|
||||
<Compile Include="Thought.vCards\vCardPropertyCollection.cs" />
|
||||
<Compile Include="Thought.vCards\vCardReader.cs" />
|
||||
<Compile Include="Thought.vCards\vCardRoot.cs" />
|
||||
<Compile Include="Thought.vCards\vCardSocialProfile.cs" />
|
||||
<Compile Include="Thought.vCards\vCardSocialProfileCollection.cs" />
|
||||
<Compile Include="Thought.vCards\vCardSource.cs" />
|
||||
@@ -158,6 +177,25 @@
|
||||
<Compile Include="View\Customs\ColumnsDialog.Designer.cs">
|
||||
<DependentUpon>ColumnsDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\Customs\CustumInputDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="View\Customs\CustumInputDialog.Designer.cs">
|
||||
<DependentUpon>CustumInputDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\Customs\ExtendedPanel.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="View\Customs\ExtendedPanel.Designer.cs">
|
||||
<DependentUpon>ExtendedPanel.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\Customs\PanelType.cs" />
|
||||
<Compile Include="View\Customs\RemovableTextBox.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="View\Customs\RemovableTextBox.Designer.cs">
|
||||
<DependentUpon>RemovableTextBox.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\EventArgs.cs" />
|
||||
<Compile Include="View\IMainView.cs" />
|
||||
<Compile Include="View\MainForm.cs">
|
||||
@@ -166,24 +204,21 @@
|
||||
<Compile Include="View\MainForm.Designer.cs">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\QRDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="View\QRDialog.Designer.cs">
|
||||
<DependentUpon>QRDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\SortableBindingList.cs" />
|
||||
<Compile Include="View\StateTextBox.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="View\UIToolbox\CollapseBox.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="View\UIToolbox\CollapsibleGroupBox.cs">
|
||||
<Compile Include="View\Customs\ExtraTextGroup.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="View\UIToolbox\ExpandingPanel.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="View\UIToolbox\ImageButton.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="View\UIToolbox\OwnerDrawButton.cs">
|
||||
<SubType>Component</SubType>
|
||||
<Compile Include="View\Customs\ExtraTextGroup.Designer.cs">
|
||||
<DependentUpon>ExtraTextGroup.cs</DependentUpon>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
@@ -211,25 +246,26 @@
|
||||
<EmbeddedResource Include="View\Customs\ColumnsDialog.resx">
|
||||
<DependentUpon>ColumnsDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="View\Customs\CustumInputDialog.resx">
|
||||
<DependentUpon>CustumInputDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="View\Customs\ExtendedPanel.resx">
|
||||
<DependentUpon>ExtendedPanel.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="View\Customs\RemovableTextBox.resx">
|
||||
<DependentUpon>RemovableTextBox.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="View\MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="View\UIToolbox\CollapseBox.resx">
|
||||
<DependentUpon>CollapseBox.cs</DependentUpon>
|
||||
<EmbeddedResource Include="View\Customs\ExtraTextGroup.resx">
|
||||
<DependentUpon>ExtraTextGroup.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="View\UIToolbox\CollapsibleGroupBox.resx">
|
||||
<DependentUpon>CollapsibleGroupBox.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="View\UIToolbox\ExpandingPanel.resx">
|
||||
<DependentUpon>ExpandingPanel.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="View\UIToolbox\ImageButton.resx">
|
||||
<DependentUpon>ImageButton.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="View\UIToolbox\OwnerDrawButton.resx">
|
||||
<DependentUpon>OwnerDrawButton.cs</DependentUpon>
|
||||
<EmbeddedResource Include="View\QRDialog.resx">
|
||||
<DependentUpon>QRDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<None Include="app.config" />
|
||||
<None Include="Libs\QRCoder\Assets\nuget-readme.md" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
@@ -246,6 +282,7 @@
|
||||
<Content Include="assests\Close.png" />
|
||||
<Content Include="assests\icons8-close-16.png" />
|
||||
<Content Include="assests\vCard.ico" />
|
||||
<Content Include="Libs\QRCoder\Assets\nuget-icon.png" />
|
||||
<Content Include="Releases.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -21,9 +21,9 @@ namespace vCardEditor_Test
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfEmtpy);
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
|
||||
var contacts = repo.LoadContacts("file.vcf");
|
||||
repo.LoadContacts("file.vcf");
|
||||
|
||||
Assert.IsTrue(contacts.Count == 0);
|
||||
Assert.IsTrue(repo.Contacts.Count == 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -31,22 +31,24 @@ namespace vCardEditor_Test
|
||||
{
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfIncorrect);
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
|
||||
var contacts = repo.LoadContacts("file.vcf");
|
||||
repo.LoadContacts("file.vcf");
|
||||
|
||||
Assert.IsTrue(contacts.Count == 0);
|
||||
Assert.IsTrue(repo.Contacts.Count == 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void NewFileOpened_Utf8Entry_Test()
|
||||
{
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfUtf8Entry);
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
var contacts = repo.LoadContacts("file.vcf");
|
||||
|
||||
Assert.AreEqual(contacts[0].Name, "Oum Alaâ");
|
||||
Assert.AreEqual(repo.Contacts[0].Name, "Oum Alaâ");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -54,9 +56,10 @@ namespace vCardEditor_Test
|
||||
{
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfOneEntry);
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
var contacts = repo.LoadContacts("file.vcf");
|
||||
Assert.IsTrue(contacts[0].card.DeliveryAddresses.FirstOrDefault().AddressType.Contains(vCardDeliveryAddressTypes.Work));
|
||||
Assert.IsTrue(repo.Contacts[0].card.DeliveryAddresses.FirstOrDefault().AddressType.Contains(vCardDeliveryAddressTypes.Work));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -64,7 +67,8 @@ namespace vCardEditor_Test
|
||||
{
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfFourEntry);
|
||||
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
repo.LoadContacts("file.vcf");
|
||||
repo.Contacts[0].isDirty=true;
|
||||
@@ -85,6 +89,7 @@ namespace vCardEditor_Test
|
||||
{
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfFourEntry);
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
repo.LoadContacts("file.vcf");
|
||||
@@ -94,7 +99,7 @@ namespace vCardEditor_Test
|
||||
|
||||
|
||||
var card = repo.Contacts[0].card;
|
||||
Assert.AreEqual(card.Phones.GetFirstChoice(vCardPhoneTypes.Cellular).FullNumber, string.Empty);
|
||||
Assert.AreEqual(card.Phones.Count, 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -102,6 +107,7 @@ namespace vCardEditor_Test
|
||||
{
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfFourEntry);
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
repo.LoadContacts("file.vcf");
|
||||
repo.Contacts[2].isDirty = true;
|
||||
@@ -120,6 +126,7 @@ namespace vCardEditor_Test
|
||||
{
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfFourEntry);
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
repo.LoadContacts("file.vcf");
|
||||
repo.Contacts[3].isDirty = true;
|
||||
@@ -136,6 +143,7 @@ namespace vCardEditor_Test
|
||||
{
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfWikiv21);
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
repo.LoadContacts("file.vcf");
|
||||
repo.Contacts[0].isDirty = true;
|
||||
@@ -145,5 +153,33 @@ namespace vCardEditor_Test
|
||||
var card = repo.Contacts[0].card;
|
||||
Assert.IsNull(card.Phones.GetFirstChoice(vCardPhoneTypes.Cellular));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddEmptyContact_ContactNotNull_Test()
|
||||
{
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfOneEntry);
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
repo.LoadContacts("file.vcf");
|
||||
|
||||
repo.AddEmptyContact();
|
||||
|
||||
|
||||
Assert.IsTrue(repo.Contacts.Count > 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddEmptyContact_ContactIsNull_Test()
|
||||
{
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
|
||||
repo.AddEmptyContact();
|
||||
|
||||
|
||||
Assert.IsTrue(repo.Contacts.Count == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace vCardEditor_Test
|
||||
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfOneEntry);
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
repo.GetExtension(Arg.Any<string>()).Returns(".vcf");
|
||||
var view = Substitute.For<IMainView>();
|
||||
@@ -57,6 +58,7 @@ namespace vCardEditor_Test
|
||||
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfThreeEntry);
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
repo.GetExtension(Arg.Any<string>()).Returns(".vcf");
|
||||
var view = Substitute.For<IMainView>();
|
||||
@@ -90,6 +92,8 @@ namespace vCardEditor_Test
|
||||
fileHandler.Received().MoveFile("aaa.vcf", "aaa.vcf.old0");
|
||||
}
|
||||
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void SaveFile_ExistAlready_Test()
|
||||
{
|
||||
@@ -115,6 +119,7 @@ namespace vCardEditor_Test
|
||||
{
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfThreeEntry);
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
repo.GetExtension(Arg.Any<string>()).Returns(".vcf");
|
||||
var view = Substitute.For<IMainView>();
|
||||
@@ -139,6 +144,7 @@ namespace vCardEditor_Test
|
||||
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfOneEntry);
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
var view = Substitute.For<IMainView>();
|
||||
view.SelectedContactIndex.Returns(0);
|
||||
@@ -157,6 +163,7 @@ namespace vCardEditor_Test
|
||||
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfOneEntryWithTwoAddress);
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
var view = Substitute.For<IMainView>();
|
||||
view.SelectedContactIndex.Returns(0);
|
||||
@@ -165,7 +172,7 @@ namespace vCardEditor_Test
|
||||
|
||||
view.AddressRemoved += Raise.EventWith(new EventArg<int>(0));
|
||||
|
||||
Assert.AreEqual(1, contact[0].card.DeliveryAddresses.Count);
|
||||
Assert.AreEqual(1, repo.Contacts[0].card.DeliveryAddresses.Count);
|
||||
|
||||
}
|
||||
|
||||
@@ -175,6 +182,7 @@ namespace vCardEditor_Test
|
||||
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfOneEntryWithTwoAddress);
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
var view = Substitute.For<IMainView>();
|
||||
view.SelectedContactIndex.Returns(0);
|
||||
@@ -186,8 +194,8 @@ namespace vCardEditor_Test
|
||||
|
||||
view.AddressAdded += Raise.EventWith(new EventArg<List<vCardDeliveryAddressTypes>>(lstvCardDeliveryAddressTypes));
|
||||
|
||||
Assert.AreEqual(2 + 1, contact[0].card.DeliveryAddresses.Count);
|
||||
Assert.AreEqual(2, contact[0].card.DeliveryAddresses[2].AddressType.Count);
|
||||
Assert.AreEqual(2 + 1, repo.Contacts[0].card.DeliveryAddresses.Count);
|
||||
Assert.AreEqual(2, repo.Contacts[0].card.DeliveryAddresses[2].AddressType.Count);
|
||||
|
||||
|
||||
}
|
||||
@@ -198,6 +206,7 @@ namespace vCardEditor_Test
|
||||
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfOneEntryWithTwoAddress);
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
var view = Substitute.For<IMainView>();
|
||||
view.SelectedContactIndex.Returns(0);
|
||||
@@ -209,8 +218,8 @@ namespace vCardEditor_Test
|
||||
|
||||
view.AddressModified += Raise.EventWith(new EventArg<List<vCardDeliveryAddressTypes>>(lstvCardDeliveryAddressTypes));
|
||||
|
||||
Assert.AreEqual(1, contact[0].card.DeliveryAddresses.Count);
|
||||
Assert.AreEqual(2, contact[0].card.DeliveryAddresses[0].AddressType.Count);
|
||||
Assert.AreEqual(1, repo.Contacts[0].card.DeliveryAddresses.Count);
|
||||
Assert.AreEqual(2, repo.Contacts[0].card.DeliveryAddresses[0].AddressType.Count);
|
||||
|
||||
}
|
||||
|
||||
@@ -219,6 +228,7 @@ namespace vCardEditor_Test
|
||||
{
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfwithInternalPhoto);
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
var view = Substitute.For<IMainView>();
|
||||
view.SelectedContactIndex.Returns(0);
|
||||
@@ -236,6 +246,7 @@ namespace vCardEditor_Test
|
||||
{
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfwithInternalPhoto);
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
var view = Substitute.For<IMainView>();
|
||||
view.SelectedContactIndex.Returns(0);
|
||||
@@ -244,8 +255,8 @@ namespace vCardEditor_Test
|
||||
|
||||
view.ModifyImage += Raise.EventWith(new EventArg<string>(""));
|
||||
|
||||
Assert.AreEqual(0, contact[0].card.Photos.Count);
|
||||
Assert.IsTrue(contact[0].isDirty);
|
||||
Assert.AreEqual(0, repo.Contacts[0].card.Photos.Count);
|
||||
Assert.IsTrue(repo.Contacts[0].isDirty);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user