Merge branch 'gettext-cs' of https://github.com/serras/SparkleShare into windows

This commit is contained in:
Hylke Bons 2012-02-27 16:34:58 +00:00
commit e118dc349a
253 changed files with 47488 additions and 9 deletions

2
.gitattributes vendored Normal file
View file

@ -0,0 +1,2 @@
.gitattributes eol=lf
.gitmodules eol=lf

12
.gitignore vendored
View file

@ -5,6 +5,10 @@
*.userprefs
*.pidb
*.gmo
*.bak
*.suo
*.sln.cache
*.user
po/POTFILES
Makefile.in
Makefile
@ -20,6 +24,8 @@ config.sub
INSTALL
aclocal.m4
autom4te.cache/
bin/
obj/
/bin/
SparkleShare/Mac/bin
install-sh
@ -33,7 +39,9 @@ SparkleLib/AssemblyInfo.cs
build/m4/shave/shave
build/m4/*.m4
build/m4/shave/shave-libtool
Defines.cs
SparkleLib/Defines.cs
SparkleLib/windows/Defines.cs
SparkleLib/windows/GlobalAssemblyInfo.cs
SparkleShare/sparkleshare
po/sparkleshare.pot
SparkleShare/Nautilus/sparkleshare-nautilus-extension.py
@ -41,3 +49,5 @@ SparkleShare/Nautilus/sparkleshare-nautilus3-extension.py
gnome-doc-utils.make
/sparkleshare-*
data/plugins/*.xml
desktop.ini
_ReSharper.*

0
.gitmodules vendored Normal file
View file

View file

@ -40,6 +40,7 @@ Contributors:
Travis Glenn Hansen <travisghansen@yahoo.com>
Vincent Untz <vuntz@gnome.org>
Will Thompson <will@willthompson.co.uk>
Konstantinos Vaggelakos <kozze89@gmail.com>
Thanks very much!

115
LICENSE.rtf Normal file
View file

@ -0,0 +1,115 @@
{\rtf1\ansi\ansicpg1252\deff0\deflang2077{\fonttbl{\f0\froman\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 Calibri;}{\f2\fnil\fcharset2 Symbol;}}
{\colortbl ;\red0\green0\blue255;}
{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\keepn\sb100\sa100\lang1053\b\f0\fs28 GNU GENERAL PUBLIC LICENSE\par
\pard\sb100\sa100\b0\fs24 Version 3, 29 June 2007\par
Copyright \'a9 2007 Free Software Foundation, Inc. <{\field{\*\fldinst{HYPERLINK "http://fsf.org/"}}{\fldrslt{\ul\cf1 http://fsf.org/}}}\f0\fs24 >\par
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.\par
\pard\keepn\sb100\sa100\b\fs28 Preamble\par
\pard\sb100\sa100\b0\fs24 The GNU General Public License is a free, copyleft license for software and other kinds of works.\par
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.\par
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.\par
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.\par
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.\par
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.\par
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.\par
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.\par
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.\par
The precise terms and conditions for copying, distribution and modification follow.\par
\pard\keepn\sb100\sa100\b\fs28 TERMS AND CONDITIONS\par
\fs24 0. Definitions.\par
\pard\sb100\sa100\b0\ldblquote This License\rdblquote refers to version 3 of the GNU General Public License.\par
\ldblquote Copyright\rdblquote also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.\par
\ldblquote The Program\rdblquote refers to any copyrightable work licensed under this License. Each licensee is addressed as \ldblquote you\rdblquote . \ldblquote Licensees\rdblquote and \ldblquote recipients\rdblquote may be individuals or organizations.\par
To \ldblquote modify\rdblquote a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a \ldblquote modified version\rdblquote of the earlier work or a work \ldblquote based on\rdblquote the earlier work.\par
A \ldblquote covered work\rdblquote means either the unmodified Program or a work based on the Program.\par
To \ldblquote propagate\rdblquote a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.\par
To \ldblquote convey\rdblquote a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.\par
An interactive user interface displays \ldblquote Appropriate Legal Notices\rdblquote to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.\par
\pard\keepn\sb100\sa100\b 1. Source Code.\par
\pard\sb100\sa100\b0 The \ldblquote source code\rdblquote for a work means the preferred form of the work for making modifications to it. \ldblquote Object code\rdblquote means any non-source form of a work.\par
A \ldblquote Standard Interface\rdblquote means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.\par
The \ldblquote System Libraries\rdblquote of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A \ldblquote Major Component\rdblquote , in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.\par
The \ldblquote Corresponding Source\rdblquote for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.\par
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.\par
The Corresponding Source for a work in source code form is that same work.\par
\pard\keepn\sb100\sa100\b 2. Basic Permissions.\par
\pard\sb100\sa100\b0 All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.\par
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.\par
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.\par
\pard\keepn\sb100\sa100\b 3. Protecting Users' Legal Rights From Anti-Circumvention Law.\par
\pard\sb100\sa100\b0 No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.\par
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.\par
\pard\keepn\sb100\sa100\b 4. Conveying Verbatim Copies.\par
\pard\sb100\sa100\b0 You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.\par
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.\par
\pard\keepn\sb100\sa100\b 5. Conveying Modified Source Versions.\par
\pard\sb100\sa100\b0 You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:\par
\pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent360{\pntxtb\'B7}}\fi-360\li720\sb100\sa100 a) The work must carry prominent notices stating that you modified it, and giving a relevant date. \par
{\pntext\f2\'B7\tab}b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to \ldblquote keep intact all notices\rdblquote . \par
{\pntext\f2\'B7\tab}c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. \par
{\pntext\f2\'B7\tab}d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. \par
\pard\sb100\sa100 A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an \ldblquote aggregate\rdblquote if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.\par
\pard\keepn\sb100\sa100\b 6. Conveying Non-Source Forms.\par
\pard\sb100\sa100\b0 You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:\par
\pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent360{\pntxtb\'B7}}\fi-360\li720\sb100\sa100 a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. \par
{\pntext\f2\'B7\tab}b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. \par
{\pntext\f2\'B7\tab}c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. \par
{\pntext\f2\'B7\tab}d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. \par
{\pntext\f2\'B7\tab}e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. \par
\pard\sb100\sa100 A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.\par
A \ldblquote User Product\rdblquote is either (1) a \ldblquote consumer product\rdblquote , which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, \ldblquote normally used\rdblquote refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.\par
\ldblquote Installation Information\rdblquote for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.\par
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).\par
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.\par
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.\par
\pard\keepn\sb100\sa100\b 7. Additional Terms.\par
\pard\sb100\sa100\b0\ldblquote Additional permissions\rdblquote are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.\par
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.\par
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:\par
\pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent360{\pntxtb\'B7}}\fi-360\li720\sb100\sa100 a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or \par
{\pntext\f2\'B7\tab}b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or \par
{\pntext\f2\'B7\tab}c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or \par
{\pntext\f2\'B7\tab}d) Limiting the use for publicity purposes of names of licensors or authors of the material; or \par
{\pntext\f2\'B7\tab}e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or \par
{\pntext\f2\'B7\tab}f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. \par
\pard\sb100\sa100 All other non-permissive additional terms are considered \ldblquote further restrictions\rdblquote within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.\par
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.\par
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.\par
\pard\keepn\sb100\sa100\b 8. Termination.\par
\pard\sb100\sa100\b0 You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).\par
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.\par
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.\par
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.\par
\pard\keepn\sb100\sa100\b 9. Acceptance Not Required for Having Copies.\par
\pard\sb100\sa100\b0 You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.\par
\pard\keepn\sb100\sa100\b 10. Automatic Licensing of Downstream Recipients.\par
\pard\sb100\sa100\b0 Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.\par
An \ldblquote entity transaction\rdblquote is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.\par
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.\par
\pard\keepn\sb100\sa100\b 11. Patents.\par
\pard\sb100\sa100\b0 A \ldblquote contributor\rdblquote is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's \ldblquote contributor version\rdblquote .\par
A contributor's \ldblquote essential patent claims\rdblquote are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, \ldblquote control\rdblquote includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.\par
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.\par
In the following three paragraphs, a \ldblquote patent license\rdblquote is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To \ldblquote grant\rdblquote such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.\par
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. \ldblquote Knowingly relying\rdblquote means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.\par
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.\par
A patent license is \ldblquote discriminatory\rdblquote if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.\par
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.\par
\pard\keepn\sb100\sa100\b 12. No Surrender of Others' Freedom.\par
\pard\sb100\sa100\b0 If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.\par
\pard\keepn\sb100\sa100\b 13. Use with the GNU Affero General Public License.\par
\pard\sb100\sa100\b0 Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.\par
\pard\keepn\sb100\sa100\b 14. Revised Versions of this License.\par
\pard\sb100\sa100\b0 The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.\par
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License \ldblquote or any later version\rdblquote applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.\par
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.\par
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.\par
\pard\keepn\sb100\sa100\b 15. Disclaimer of Warranty.\par
\pard\sb100\sa100\b0 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \ldblquote AS IS\rdblquote WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\par
\pard\keepn\sb100\sa100\b 16. Limitation of Liability.\par
\pard\sb100\sa100\b0 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\par
\pard\keepn\sb100\sa100\b 17. Interpretation of Sections 15 and 16.\par
\pard\sb100\sa100\b0 If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.\par
END OF TERMS AND CONDITIONS\lang29\f1\fs22\par
}

View file

@ -147,6 +147,33 @@ Copy `/Library/Frameworks/Mono.framework/Versions/Current/lib/libintl.dylib` to
Now you should have a working bundle that you can run.
## Build on Windows
* Install [.NET Framework 4.0](http://www.microsoft.com/download/en/details.aspx?id=17851) (if not installed yet)
* Install [msysGit](http://code.google.com/p/msysgit/downloads/detail?name=Git-1.7.8-preview20111206.exe)
* Change install location to `C:\msysgit` (location is hard-coded in the build scrits)
* Use default settings for all other questions during installation
* Copy the entire contents of the msysGit folder to `{clone folder}\bin\msysgit`
* _Build step_: Open a command shell (available in Start Menu > Accessories > Command Prompt) and execute (Note to Windows 7 x64 users: change the WinDirNet variable in build.cmd to "%WinDir%\Microsoft.NET\Framework64")
C:
cd {clone folder}
cd SparkleShare\Windows
build
* `{clone folder}\bin` should now contain `SparkleLib.dll` and `SparkleShare.exe`, apart from folders `plugins`, `po` and `msysgit`
* If you want to build the Windows installer download and install [WiX 3.6](http://wix.sourceforge.net/)
* _Installer build step_: Then open a command shell and write almost the same as before, but with `installer` at the end
C:
cd {clone folder}
cd SparkleShare\Windows
build installer
## Info

View file

@ -94,7 +94,7 @@ namespace SparkleLib {
this.git = new SparkleGit (SparkleConfig.DefaultConfig.TmpPath,
"clone " +
"--progress " + // Redirects progress stats to standarderror
"\"" + RemoteUrl + "\" " + "\"" + TargetFolder + "\"");
"\"" + RemoteUrl + "\" " + "\"" + SparkleHelpers.NormalizeSeparatorsToOS(TargetFolder) + "\"");
this.git.StartInfo.RedirectStandardError = true;
this.git.Start ();

2
SparkleLib/Git/SparkleRepoGit.cs Executable file → Normal file
View file

@ -560,7 +560,7 @@ namespace SparkleLib {
List <SparkleChangeSet> change_sets = new List <SparkleChangeSet> ();
// Console.InputEncoding = System.Text.Encoding.Unicode;
Console.OutputEncoding = System.Text.Encoding.Unicode;
// Console.OutputEncoding = System.Text.Encoding.Unicode;
SparkleGit git_log = new SparkleGit (LocalPath, "log -" + count + " --raw -M --date=iso");
git_log.Start ();

View file

@ -189,8 +189,14 @@ namespace SparkleLib {
string ssh_config_path = Path.Combine (path, ".ssh");
string ssh_config_file_path = SparkleHelpers.CombineMore (path, ".ssh", "config");
string ssh_config = "IdentityFile " +
Path.Combine (SparkleConfig.ConfigPath, "sparkleshare." + User.Email + ".key");
string ssh_key_path = SparkleHelpers.NormalizeSeparatorsToOS(
Path.Combine(SparkleConfig.ConfigPath, "sparkleshare." + User.Email + ".key"));
if (SparkleHelpers.IsWindows && ssh_key_path.IndexOf(' ') >= 0)
{
ssh_key_path = "\"" + ssh_key_path + "\"";
}
string ssh_config = "IdentityFile " + ssh_key_path;
if (!Directory.Exists (ssh_config_path))
Directory.CreateDirectory (ssh_config_path);

View file

@ -98,6 +98,29 @@ namespace SparkleLib {
{
return target.Replace (source + Path.DirectorySeparatorChar, "");
}
public static bool IsWindows
{
get
{
PlatformID platform = Environment.OSVersion.Platform;
return (platform == PlatformID.Win32NT
|| platform == PlatformID.Win32S
|| platform == PlatformID.Win32Windows);
}
}
public static string NormalizeSeparatorsToOS(string path)
{
if (IsWindows)
{
return path.Replace('\\', '/');
}
else
{
return path;
}
}
}
}

View file

@ -159,7 +159,7 @@ namespace SparkleLib {
this.is_connected = false;
this.is_connecting = false;;
if (this.socket != null)
if (this.socket != null)
this.socket.Close ();
OnDisconnected ("Ping timeout");

View file

@ -0,0 +1,14 @@
/*
* AssemblyInfo.cs
*
* This is free software. See COPYING for details.
*/
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle ("SparkleLib")]
[assembly: AssemblyDescription ("SparkleShare is a simple file sharing and collaboration tool.")]
[assembly: Guid ("38092E48-5DCC-4d23-8109-9D994E710ACF")]

View file

@ -0,0 +1,46 @@
// SparkleShare, an instant update workflow to Git.
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
<#@ template language="C#v3.5" HostSpecific="true" #>
<#@ output extension="cs" #>
<#@ include file="getversion.tt" #>
<#
PlatformID platform = Environment.OSVersion.Platform;
bool IsWindows = (platform == PlatformID.Win32NT
|| platform == PlatformID.Win32S
|| platform == PlatformID.Win32Windows
|| platform == PlatformID.WinCE);
#>
using System;
namespace SparkleLib {
public class Defines {
public const string VERSION = "<#= VERSION #>";
public const string LOCALE_DIR = "@prefix@/share/locale";
public const string DATAROOTDIR = "@expanded_datadir@";
public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@";
public const string PREFIX = "@prefix@";
public const string OPEN_COMMAND = "xdg-open";
}
}

View file

@ -0,0 +1,25 @@
/*
* GlobalAssemblyInfo.cs
*
* This is free software. See COPYING for details.
*/
<#@ template language="C#v3.5" HostSpecific="true" #>
<#@ output extension="cs" #>
<#@ include file="getversion.tt" #>
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyProduct("SparkleShare")]
[assembly: AssemblyVersion("<#= ASM_VERSION #>")]
[assembly: AssemblyFileVersion("<#= ASM_FILE_VERSION #>")]
[assembly: AssemblyInformationalVersion("<#= VERSION #>")]
#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif

View file

@ -0,0 +1,176 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{2C914413-B31C-4362-93C7-1AE34F09112A}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>SparkleLib</RootNamespace>
<AssemblyName>SparkleLib</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\bin</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\bin</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Git\SparkleFetcherGit.cs">
<Link>SparkleFetcherGit.cs</Link>
</Compile>
<Compile Include="..\Git\SparkleGit.cs">
<Link>SparkleGit.cs</Link>
<SubType>Component</SubType>
</Compile>
<Compile Include="..\Git\SparkleRepoGit.cs">
<Link>SparkleRepoGit.cs</Link>
</Compile>
<Compile Include="..\SparkleAnnouncement.cs">
<Link>SparkleAnnouncement.cs</Link>
</Compile>
<Compile Include="..\SparkleConfig.cs">
<Link>SparkleConfig.cs</Link>
</Compile>
<Compile Include="..\SparkleExtensions.cs">
<Link>SparkleExtensions.cs</Link>
</Compile>
<Compile Include="..\SparkleListenerFactory.cs">
<Link>SparkleListenerFactory.cs</Link>
</Compile>
<Compile Include="..\SparkleRepoBase.cs">
<Link>SparkleRepoBase.cs</Link>
</Compile>
<Compile Include="..\SparkleUser.cs">
<Link>SparkleUser.cs</Link>
</Compile>
<Compile Include="..\SparkleWatcher.cs">
<Link>SparkleWatcher.cs</Link>
<SubType>Component</SubType>
</Compile>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Defines.cs">
<DependentUpon>Defines.tt</DependentUpon>
<SubType>Code</SubType>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</Compile>
<Compile Include="..\SparkleFetcherBase.cs" />
<Compile Include="..\SparkleHelpers.cs" />
<Compile Include="..\SparkleChangeSet.cs" />
<Compile Include="..\SparkleListenerBase.cs" />
<Compile Include="..\SparkleListenerTcp.cs" />
<Compile Include="..\SparkleBackend.cs" />
<Compile Include="GlobalAssemblyInfo.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>GlobalAssemblyInfo.tt</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
<Service Include="{B4F97281-0DBD-4835-9ED8-7DFB966E87FF}" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
<Visible>False</Visible>
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
<Visible>False</Visible>
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="Defines.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Defines.cs</LastGenOutput>
</None>
<None Include="GlobalAssemblyInfo.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>GlobalAssemblyInfo.cs</LastGenOutput>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<MonoDevelop>
<Properties InternalTargetFrameworkVersion="3.5">
<MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="true" RelativeMakefileName="Makefile.am">
<BuildFilesVar Sync="true" Name="SOURCES" />
<DeployFilesVar />
<ResourcesVar />
<OthersVar />
<GacRefVar />
<AsmRefVar />
<ProjectRefVar />
</MonoDevelop.Autotools.MakefileInfo>
</Properties>
</MonoDevelop>
<VisualStudio />
</ProjectExtensions>
<PropertyGroup>
<PreBuildEvent>$(ProjectDir)transform_tt.cmd</PreBuildEvent>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,41 @@
<#@ import namespace="System" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Diagnostics" #>
<#@ import namespace="System.Text.RegularExpressions" #>
<#
// Add msysgit to path, as we cannot asume it is added to the path
// Asume it is installed in @"C:\msysgit\bin" for now
string MSysGit=@"C:\msysgit";
string newPath = MSysGit + @"\bin" + ";"
+ MSysGit + @"\mingw\bin" + ";"
+ MSysGit + @"\cmd" + ";"
+ System.Environment.ExpandEnvironmentVariables ("%PATH%");
System.Environment.SetEnvironmentVariable ("PATH", newPath);
Process process = new Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.FileName = "git";
process.StartInfo.Arguments = "describe --tags";
process.StartInfo.WorkingDirectory = Path.GetDirectoryName(Host.TemplateFile);
process.Start();
String DescribeOutput=process.StandardOutput.ReadLine();
Match m = Regex.Match(DescribeOutput, @"(\d+)\.(\d+)(?:-rc(\d+))?-(\d+)");
int[] version = new int [4];
for(int i=1; i <= 4; i++)
Int32.TryParse(m.Groups[i].Value, out version[i-1]);
String VERSION=DescribeOutput;
String ASM_VERSION=String.Format("{0}.{1}",version[0],version[1]);
String ASM_FILE_VERSION=String.Format("{0}.{1}.{2}.{3}",version[0],version[1],version[2],version[3]);
#>
// VERSION=<#= VERSION #>
// ASM_VERSION=<#= ASM_VERSION #>

View file

@ -0,0 +1,11 @@
@echo off
cd %~dp0
set TextTransform=..\..\SparkleShare\Windows\tools\TextTemplating\bin\TextTransform.exe
if not exist %TextTransform% call ..\..\SparkleShare\Windows\tools\TextTemplating\build.cmd
echo running texttransform..
%TextTransform% -out Defines.cs Defines.tt
%TextTransform% -out GlobalAssemblyInfo.cs GlobalAssemblyInfo.tt

0
SparkleShare/Program.cs Executable file → Normal file
View file

10
SparkleShare/SparkleControllerBase.cs Executable file → Normal file
View file

@ -27,7 +27,9 @@ using System.Text.RegularExpressions;
using System.Threading;
using System.Xml;
#if __MonoCS__
using Mono.Unix;
#endif
using SparkleLib;
namespace SparkleShare {
@ -121,7 +123,7 @@ namespace SparkleShare {
// Short alias for the translations
public static string _ (string s)
{
return Catalog.GetString (s);
return Program._(s);
}
@ -1131,14 +1133,18 @@ namespace SparkleShare {
}
public void Quit ()
public virtual void Quit ()
{
lock (this.repo_lock) {
foreach (SparkleRepoBase repo in Repositories)
repo.Dispose ();
}
#if __MonoCS__
Environment.Exit (0);
#else
System.Windows.Forms.Application.Exit();
#endif
}

0
SparkleShare/SparkleExtensions.cs Executable file → Normal file
View file

0
SparkleShare/SparkleStatusIcon.cs Executable file → Normal file
View file

9
SparkleShare/SparkleUI.cs Executable file → Normal file
View file

@ -23,9 +23,13 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
#if __MonoCS__
using Gtk;
using Mono.Unix;
using Mono.Unix.Native;
#else
using System.Windows.Forms;
#endif
using SparkleLib;
namespace SparkleShare {
@ -45,17 +49,19 @@ namespace SparkleShare {
// Short alias for the translations
public static string _(string s)
{
return Catalog.GetString (s);
return Program._ (s);
}
public SparkleUI ()
{
// Initialize the application
#if __MonoCS__
Application.Init ();
// Use translations
Catalog.Init (Defines.GETTEXT_PACKAGE, Defines.LOCALE_DIR);
#endif
Setup = new SparkleSetup ();
EventLog = new SparkleEventLog ();
@ -72,6 +78,7 @@ namespace SparkleShare {
public void Run ()
{
Application.Run ();
StatusIcon.Dispose ();
}
}
}

View file

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CefSharp;
using System.IO;
namespace SparkleShare {
class ApplicationSchemeHandler : ISchemeHandler {
#region ISchemeHandler Members
public bool ProcessRequest (IRequest request, ref string mimeType, ref Stream stream)
{
if (request.Url.EndsWith (".png")) {
System.Drawing.Bitmap Image=null;
if (request.Url.EndsWith ("avatar-default-32.png"))
Image = Icons.avatar_default_32;
else if (request.Url.EndsWith ("document-added-12.png"))
Image = Icons.document_added_12;
else if (request.Url.EndsWith ("document-edited-12.png"))
Image = Icons.document_edited_12;
else if (request.Url.EndsWith ("document-deleted-12.png"))
Image = Icons.document_deleted_12;
else if (request.Url.EndsWith ("document-moved-12.png"))
Image = Icons.document_moved_12;
if (Image != null) {
stream = new MemoryStream ();
Image.Save (stream, System.Drawing.Imaging.ImageFormat.Png);
stream.Seek (0, SeekOrigin.Begin);
mimeType = "image/png";
return true;
}
} else if (request.Url.EndsWith (".js")) {
string Text = null;
if (request.Url.EndsWith ("jquery.js"))
Text = Properties.Resources.jquery_js;
if (Text != null) {
stream = new MemoryStream (Encoding.UTF8.GetPreamble ().Concat (Encoding.UTF8.GetBytes (Text)).ToArray ());
mimeType = "application/javascript";
return true;
}
}
return false;
}
#endregion
}
public class ApplicationSchemeHandlerFactory : ISchemeHandlerFactory {
public ISchemeHandler Create ()
{
return new ApplicationSchemeHandler ();
}
}
}

View file

@ -0,0 +1,14 @@
/*
* AssemblyInfo.cs
*
* This is free software. See COPYING for details.
*/
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle ("SparkleShare")]
[assembly: AssemblyDescription ("SparkleShare is a simple file sharing and collaboration tool.")]
[assembly: Guid ("A8F34995-DB20-4bf2-AA27-869B15B8C2F9")]

View file

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CefSharp;
using System.IO;
namespace SparkleShare {
class FileSchemeHandler : ISchemeHandler {
#region ISchemeHandler Members
public bool ProcessRequest (IRequest request, ref string mimeType, ref Stream stream)
{
return false;
}
#endregion
}
public class FileSchemeHandlerFactory : ISchemeHandlerFactory {
public ISchemeHandler Create ()
{
return new FileSchemeHandler ();
}
}
}

308
SparkleShare/Windows/Icons.Designer.cs generated Normal file
View file

@ -0,0 +1,308 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Este código fue generado por una herramienta.
// Versión del motor en tiempo de ejecución:2.0.50727.3625
//
// Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si
// se vuelve a generar el código.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SparkleShare {
using System;
/// <summary>
/// Clase de recurso con establecimiento inflexible de tipos, para buscar cadenas traducidas, etc.
/// </summary>
// StronglyTypedResourceBuilder generó automáticamente esta clase
// a través de una herramienta como ResGen o Visual Studio.
// Para agregar o quitar un miembro, edite el archivo .ResX y, a continuación, vuelva a ejecutar ResGen
// con la opción /str o vuelva a generar su proyecto de VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Icons {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Icons() {
}
/// <summary>
/// Devuelve la instancia de ResourceManager almacenada en caché utilizada por esta clase.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SparkleShare.Icons", typeof(Icons).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Reemplaza la propiedad CurrentUICulture del subproceso actual para todas las
/// búsquedas de recursos mediante esta clase de recurso con establecimiento inflexible de tipos.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
internal static System.Drawing.Bitmap about {
get {
object obj = ResourceManager.GetObject("about", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap avatar_default {
get {
object obj = ResourceManager.GetObject("avatar_default", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap avatar_default_16 {
get {
object obj = ResourceManager.GetObject("avatar_default_16", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap avatar_default_22 {
get {
object obj = ResourceManager.GetObject("avatar_default_22", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap avatar_default_24 {
get {
object obj = ResourceManager.GetObject("avatar_default_24", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap avatar_default_32 {
get {
object obj = ResourceManager.GetObject("avatar_default_32", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap avatar_default_48 {
get {
object obj = ResourceManager.GetObject("avatar_default_48", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap dialog_error_16 {
get {
object obj = ResourceManager.GetObject("dialog_error_16", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap dialog_error_24 {
get {
object obj = ResourceManager.GetObject("dialog_error_24", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap document_added_12 {
get {
object obj = ResourceManager.GetObject("document_added_12", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap document_deleted_12 {
get {
object obj = ResourceManager.GetObject("document_deleted_12", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap document_edited_12 {
get {
object obj = ResourceManager.GetObject("document_edited_12", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap document_moved_12 {
get {
object obj = ResourceManager.GetObject("document_moved_12", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap folder_sparkleshare_16 {
get {
object obj = ResourceManager.GetObject("folder_sparkleshare_16", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap folder_sparkleshare_22 {
get {
object obj = ResourceManager.GetObject("folder_sparkleshare_22", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap folder_sparkleshare_24 {
get {
object obj = ResourceManager.GetObject("folder_sparkleshare_24", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap folder_sparkleshare_256 {
get {
object obj = ResourceManager.GetObject("folder_sparkleshare_256", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap folder_sparkleshare_32 {
get {
object obj = ResourceManager.GetObject("folder_sparkleshare_32", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap folder_sparkleshare_48 {
get {
object obj = ResourceManager.GetObject("folder_sparkleshare_48", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap list_point_16 {
get {
object obj = ResourceManager.GetObject("list_point_16", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap process_syncing_sparkleshare_24 {
get {
object obj = ResourceManager.GetObject("process_syncing_sparkleshare_24", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap process_syncing_sparkleshare_i_24 {
get {
object obj = ResourceManager.GetObject("process_syncing_sparkleshare_i_24", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap process_syncing_sparkleshare_ii_24 {
get {
object obj = ResourceManager.GetObject("process_syncing_sparkleshare_ii_24", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap process_syncing_sparkleshare_iii_24 {
get {
object obj = ResourceManager.GetObject("process_syncing_sparkleshare_iii_24", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap process_syncing_sparkleshare_iiii_24 {
get {
object obj = ResourceManager.GetObject("process_syncing_sparkleshare_iiii_24", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap process_syncing_sparkleshare_iiiii_24 {
get {
object obj = ResourceManager.GetObject("process_syncing_sparkleshare_iiiii_24", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap process_working_22 {
get {
object obj = ResourceManager.GetObject("process_working_22", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap side_splash {
get {
object obj = ResourceManager.GetObject("side_splash", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Icon sparkleshare {
get {
object obj = ResourceManager.GetObject("sparkleshare", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
internal static System.Drawing.Bitmap sparkleshare_syncing_error_24 {
get {
object obj = ResourceManager.GetObject("sparkleshare_syncing_error_24", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap sparkleshare_windows_status {
get {
object obj = ResourceManager.GetObject("sparkleshare_windows_status", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap tutorial_slide_1 {
get {
object obj = ResourceManager.GetObject("tutorial_slide_1", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap tutorial_slide_2 {
get {
object obj = ResourceManager.GetObject("tutorial_slide_2", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap tutorial_slide_3 {
get {
object obj = ResourceManager.GetObject("tutorial_slide_3", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap tutorial_slide_4 {
get {
object obj = ResourceManager.GetObject("tutorial_slide_4", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View file

@ -0,0 +1,226 @@
<?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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="avatar_default_16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\avatar-default-16.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="avatar_default_22" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\avatar-default-22.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="avatar_default_24" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\avatar-default-24.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="avatar_default_32" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\avatar-default-32.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="avatar_default_48" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\avatar-default-48.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="avatar_default" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\avatar-default.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="dialog_error_16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\dialog-error-16.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="dialog_error_24" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\dialog-error-24.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="document_added_12" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\document-added-12.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="document_deleted_12" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\document-deleted-12.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="document_edited_12" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\document-edited-12.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="document_moved_12" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\document-moved-12.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="folder_sparkleshare_16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\folder-sparkleshare-16.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="folder_sparkleshare_22" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\folder-sparkleshare-22.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="folder_sparkleshare_24" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\folder-sparkleshare-24.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="folder_sparkleshare_256" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\folder-sparkleshare-256.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="folder_sparkleshare_32" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\folder-sparkleshare-32.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="folder_sparkleshare_48" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\folder-sparkleshare-48.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="list_point_16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\list-point-16.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="process_syncing_sparkleshare_24" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\process-syncing-sparkleshare-24.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="process_syncing_sparkleshare_i_24" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\process-syncing-sparkleshare-i-24.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="process_syncing_sparkleshare_ii_24" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\process-syncing-sparkleshare-ii-24.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="process_syncing_sparkleshare_iii_24" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\process-syncing-sparkleshare-iii-24.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="process_syncing_sparkleshare_iiii_24" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\process-syncing-sparkleshare-iiii-24.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="process_syncing_sparkleshare_iiiii_24" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\process-syncing-sparkleshare-iiiii-24.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="process_working_22" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\process-working-22.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="sparkleshare_syncing_error_24" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\sparkleshare-syncing-error-24.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="sparkleshare_windows_status" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\sparkleshare-windows-status.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="sparkleshare" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\icons\sparkleshare.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="about" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\about.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="side_splash" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\side-splash.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="tutorial_slide_1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\tutorial-slide-1.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="tutorial_slide_2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\tutorial-slide-2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="tutorial_slide_3" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\tutorial-slide-3.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="tutorial_slide_4" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\data\tutorial-slide-4.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View file

@ -0,0 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>
<#@ template language="C#v3.5" HostSpecific="true" #>
<#@ output extension="resx" #>
<#@ import namespace="System" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Diagnostics" #>
<#@ import namespace="System.Text.RegularExpressions" #>
<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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<#
string RelativeDir = @"..\..\data\icons";
DirectoryInfo dir = new DirectoryInfo(RelativeDir);
foreach (FileInfo f in dir.GetFiles("*.png"))
{
string DataName = Regex.Replace(Path.ChangeExtension(f.Name, null), "[^a-zA-Z0-9_]", "_");
string FileName = Path.Combine(RelativeDir, f.Name);
#>
<data name="<#= DataName #>" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value><#= FileName #>;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<#
}
foreach (FileInfo f in dir.GetFiles("*.ico"))
{
string DataName = Regex.Replace(Path.ChangeExtension(f.Name, null), "[^a-zA-Z0-9_]", "_");
string FileName = Path.Combine(RelativeDir, f.Name);
#>
<data name="<#= DataName #>" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value><#= FileName #>;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<#
}
RelativeDir = @"..\..\data";
dir = new DirectoryInfo(RelativeDir);
foreach (FileInfo f in dir.GetFiles("*.png"))
{
string DataName = Regex.Replace(Path.ChangeExtension(f.Name, null), "[^a-zA-Z0-9_]", "_");
string FileName = Path.Combine(RelativeDir, f.Name);
#>
<data name="<#= DataName #>" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value><#= FileName #>;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<#
}
#>
</root>

View file

@ -0,0 +1,128 @@
// SparkleShare, an instant update workflow to Git.
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
namespace Notifications
{
public partial class Notification : Form
{
private Timer animationTimer;
private int startPosX;
private int startPosY;
//public new Gdk.Pixbuf Icon;
public Notification ()
{
InitializeComponent ();
TopMost = true;
ShowInTaskbar = false;
animationTimer = new Timer ();
animationTimer.Interval = 50;
animationTimer.Tick += timer_Tick;
}
public Notification (string title, string subtext)
: this()
{
this.title.Text = title;
this.subtext.Text = subtext;
}
protected override void OnLoad (EventArgs e)
{
// Move window out of screen
startPosX = Screen.PrimaryScreen.WorkingArea.Width - Width;
startPosY = Screen.PrimaryScreen.WorkingArea.Height;
SetDesktopLocation (startPosX, startPosY);
base.OnLoad (e);
// Begin animation
animationTimer.Start ();
}
protected override void OnShown (EventArgs e)
{
base.OnShown (e);
// hacky way to move the image from a Gdk.Pixbuf to a winforms bitmap
string Filename = Path.GetTempFileName ();
File.Delete (Filename);
Filename = Path.ChangeExtension (Filename, "bmp");
if (File.Exists (Filename))
File.Delete (Filename);
//this.Icon.Save (Filename, "bmp");
using (Stream s = File.OpenRead (Filename))
pictureBox1.Image = Bitmap.FromStream (s);
File.Delete (Filename);
}
void timer_Tick (object sender, EventArgs e)
{
startPosY -= 5;
if (startPosY < Screen.PrimaryScreen.WorkingArea.Height - Height)
animationTimer.Stop ();
else
SetDesktopLocation (startPosX, startPosY);
}
public void AddAction (string action, string label, ActionHandler handler)
{
}
public void RemoveAction (string action)
{
}
public void ClearActions ()
{
}
}
public enum Urgency : byte
{
Low = 0,
Normal,
Critical
}
public class ActionArgs : EventArgs
{
private string action;
public string Action
{
get { return action; }
}
public ActionArgs (string action)
{
this.action = action;
}
}
public delegate void ActionHandler (object o, ActionArgs args);
}

View file

@ -0,0 +1,96 @@
namespace Notifications
{
partial class Notification
{
/// <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.pictureBox1 = new System.Windows.Forms.PictureBox ();
this.title = new System.Windows.Forms.Label ();
this.subtext = new System.Windows.Forms.Label ();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit ();
this.SuspendLayout ();
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point (12, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size (40, 42);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// title
//
this.title.AutoSize = true;
this.title.Font = new System.Drawing.Font ("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.title.Location = new System.Drawing.Point (58, 9);
this.title.Name = "title";
this.title.Size = new System.Drawing.Size (28, 13);
this.title.TabIndex = 1;
this.title.Text = "title";
//
// subtext
//
this.subtext.AutoSize = true;
this.subtext.Location = new System.Drawing.Point (58, 22);
this.subtext.MaximumSize = new System.Drawing.Size (171, 0);
this.subtext.Name = "subtext";
this.subtext.Size = new System.Drawing.Size (41, 13);
this.subtext.TabIndex = 2;
this.subtext.Text = "subtext";
//
// Notification
//
this.AutoScaleDimensions = new System.Drawing.SizeF (6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size (241, 64);
this.ControlBox = false;
this.Controls.Add (this.subtext);
this.Controls.Add (this.title);
this.Controls.Add (this.pictureBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Notification";
this.Opacity = 0.8;
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit ();
this.ResumeLayout (false);
this.PerformLayout ();
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label title;
private System.Windows.Forms.Label subtext;
}
}

View 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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -0,0 +1,172 @@
// SparkleShare, a collaboration and sharing tool.
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
#if __MonoCS__
using Mono.Unix;
//using Mono.Unix.Native;
#endif
using SparkleLib;
namespace SparkleShare {
// This is SparkleShare!
public class Program {
public static SparkleController Controller;
public static SparkleUI UI;
// Short alias for the translations
public static string _ (string s)
{
#if __MonoCS__
return Catalog.GetString (s);
#else
return Strings.T(s);
#endif
}
#if !__MonoCS__
public static void TranslateWinForm (System.Windows.Forms.Form form)
{
form.Text = Program._ (form.Text);
foreach (var label in form.Controls.All ().OfType<System.Windows.Forms.Label> ()) {
label.Text = Program._ (label.Text);
}
foreach (var button in form.Controls.All ().OfType<System.Windows.Forms.Button> ()) {
button.Text = Program._ (button.Text);
}
}
#endif
#if !__MonoCS__
[STAThread]
#endif
public static void Main (string [] args)
{
SetUiCulture();
// Parse the command line options
bool show_help = false;
OptionSet option_set = new OptionSet () {
{ "v|version", _("Print version information"), v => { PrintVersion (); } },
{ "h|help", _("Show this help text"), v => show_help = v != null }
};
try {
option_set.Parse (args);
} catch (OptionException e) {
Console.Write ("SparkleShare: ");
Console.WriteLine (e.Message);
Console.WriteLine ("Try `sparkleshare --help' for more information.");
}
if (show_help)
ShowHelp (option_set);
// Initialize the controller this way so that
// there aren't any exceptions in the OS specific UI's
Controller = new SparkleController ();
Controller.Initialize ();
if (Controller != null) {
UI = new SparkleUI ();
UI.Run ();
}
#if !__MonoCS__
// For now we must do GC.Collect to free some internal handles, otherwise
// in debug mode you can got assertion message.
GC.Collect (GC.MaxGeneration, GCCollectionMode.Forced);
GC.WaitForPendingFinalizers ();
CefSharp.CEF.Shutdown (); // Shutdown CEF.
#endif
}
public static void SetUiCulture()
{
//var culture = CultureInfo.GetCultureInfo ("en"); // FIXME: test only
//System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
}
// Prints the help output
public static void ShowHelp (OptionSet option_set)
{
Console.WriteLine (" ");
Console.WriteLine (_("SparkleShare, a collaboration and sharing tool."));
Console.WriteLine (_("Copyright (C) 2010 Hylke Bons"));
Console.WriteLine (" ");
Console.WriteLine (_("This program comes with ABSOLUTELY NO WARRANTY."));
Console.WriteLine (" ");
Console.WriteLine (_("This is free software, and you are welcome to redistribute it "));
Console.WriteLine (_("under certain conditions. Please read the GNU GPLv3 for details."));
Console.WriteLine (" ");
Console.WriteLine (_("SparkleShare automatically syncs Git repositories in "));
Console.WriteLine (_("the ~/SparkleShare folder with their remote origins."));
Console.WriteLine (" ");
Console.WriteLine (_("Usage: sparkleshare [start|stop|restart] [OPTION]..."));
Console.WriteLine (_("Sync SparkleShare folder with remote repositories."));
Console.WriteLine (" ");
Console.WriteLine (_("Arguments:"));
option_set.WriteOptionDescriptions (Console.Out);
Environment.Exit (0);
}
// Prints the version information
public static void PrintVersion ()
{
Console.WriteLine (_("SparkleShare " + Defines.VERSION));
Environment.Exit (0);
}
#if __MonoCS__
// Strange magic needed by SetProcessName ()
[DllImport ("libc")]
private static extern int prctl (int option, byte [] arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5);
#endif
// Sets the Unix process name to 'sparkleshare' instead of 'mono'
private static void SetProcessName (string name)
{
#if __MonoCS__
try {
if (prctl (15, Encoding.ASCII.GetBytes (name + "\0"), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero) != 0)
throw new ApplicationException ("Error setting process name: " +
Mono.Unix.Native.Stdlib.GetLastError ());
} catch (EntryPointNotFoundException) {
Console.WriteLine ("SetProcessName: Entry point not found");
}
#endif
}
}
}

View file

@ -0,0 +1,150 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.3053
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SparkleShare.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SparkleShare.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to &lt;div class=&apos;day-entry&apos;&gt;
/// &lt;div class=&apos;day-entry-header&apos;&gt;
/// &lt;!-- $day-entry-header --&gt;
/// &lt;/div&gt;
/// &lt;div class=&apos;day-entry-content&apos;&gt;
/// &lt;!-- $day-entry-content --&gt;
/// &lt;/div&gt;
///&lt;/div&gt;
///.
/// </summary>
internal static string day_entry_html {
get {
return ResourceManager.GetString("day_entry_html", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;div class=&apos;event-entry&apos; style=&apos;background-image: url(&quot;&lt;!-- $event-avatar-url --&gt;&quot;);&apos;&gt;
/// &lt;div class=&apos;event-user-name&apos;&gt;&lt;!-- $event-user-name --&gt;&lt;/div&gt;
/// &lt;div class=&apos;event-folder&apos;&gt;&lt;!-- $event-folder --&gt;&lt;/div&gt;
///
/// &lt;!-- $event-entry-content --&gt;
///
/// &lt;div class=&quot;clearer&quot;&gt;&lt;/div&gt;
/// &lt;div class=&quot;event-timestamp&quot;&gt;&lt;!-- $event-time --&gt;&lt;/div&gt;
/// &lt;div class=&quot;action note&quot;&gt;Add note&lt;/div&gt;
/// &lt;div class=&quot;action show&quot;&gt;Show all&lt;/div&gt;
///
/// &lt;div class=&quot;clearer&quot;&gt;&lt;/div&gt;
///
/// &lt;div class=&quot;comments-section&quot;&gt;
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string event_entry_html {
get {
return ResourceManager.GetString("event_entry_html", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;!doctype html&gt;
///&lt;html&gt;
/// &lt;head&gt;
/// &lt;title&gt;SparkleShare Event Log&lt;/title&gt;
/// &lt;script type=&quot;text/javascript&quot; src=&quot;&lt;!-- $jquery-url --&gt;&quot;&gt;&lt;/script&gt;
/// &lt;script type=&quot;text/javascript&quot;&gt;
/// $(document).ready(function () {
/// $(&apos;.comments-section&apos;).each (function () {
/// if ($(this).find (&apos;.comments&apos;).children ().size () &lt; 1) {
/// $(this).hide ();
/// }
/// });
///
/// $(&apos;.buddy-icon&apos;).each (function () {
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string event_log_html {
get {
return ResourceManager.GetString("event_log_html", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to /*!
/// * jQuery JavaScript Library v1.6.1
/// * http://jquery.com/
/// *
/// * Copyright 2011, John Resig
/// * Dual licensed under the MIT or GPL Version 2 licenses.
/// * http://jquery.org/license
/// *
/// * Includes Sizzle.js
/// * http://sizzlejs.com/
/// * Copyright 2011, The Dojo Foundation
/// * Released under the MIT, BSD, and GPL Licenses.
/// *
/// * Date: Thu May 12 15:04:36 2011 -0400
/// */
///(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!cj[a]){var [rest of string was truncated]&quot;;.
/// </summary>
internal static string jquery_js {
get {
return ResourceManager.GetString("jquery_js", resourceCulture);
}
}
}
}

View file

@ -0,0 +1,133 @@
<?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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="day_entry_html" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\..\data\html\day-entry.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="event_entry_html" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\..\data\html\event-entry.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="event_log_html" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\..\data\html\event-log.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="jquery_js" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\..\data\html\jquery.js;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
</root>

View file

@ -0,0 +1,105 @@
namespace SparkleShare {
partial class SparkleAbout {
/// <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() {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager (typeof (SparkleAbout));
this.version = new System.Windows.Forms.Label ();
this.copyright = new System.Windows.Forms.Label ();
this.emptyLabel = new System.Windows.Forms.Label ();
this.SparkleShareVersion = new System.Windows.Forms.Label ();
this.SuspendLayout ();
//
// version
//
this.version.AutoSize = true;
this.version.BackColor = System.Drawing.Color.Transparent;
this.version.ForeColor = System.Drawing.Color.LightGray;
this.version.Location = new System.Drawing.Point (302, 102);
this.version.Name = "version";
this.version.Size = new System.Drawing.Size (34, 13);
this.version.TabIndex = 1;
this.version.Text = ".........";
//
// copyright
//
this.copyright.BackColor = System.Drawing.Color.Transparent;
this.copyright.Font = new System.Drawing.Font ("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.copyright.ForeColor = System.Drawing.Color.White;
this.copyright.Location = new System.Drawing.Point (302, 135);
this.copyright.Name = "copyright";
this.copyright.Size = new System.Drawing.Size (298, 84);
this.copyright.TabIndex = 2;
this.copyright.Text = resources.GetString ("copyright.Text");
//
// emptyLabel
//
this.emptyLabel.AutoSize = true;
this.emptyLabel.Location = new System.Drawing.Point (16, 89);
this.emptyLabel.Name = "emptyLabel";
this.emptyLabel.Size = new System.Drawing.Size (0, 13);
this.emptyLabel.TabIndex = 6;
//
// SparkleShareVersion
//
this.SparkleShareVersion.AutoSize = true;
this.SparkleShareVersion.BackColor = System.Drawing.Color.Transparent;
this.SparkleShareVersion.ForeColor = System.Drawing.Color.White;
this.SparkleShareVersion.Location = new System.Drawing.Point (302, 89);
this.SparkleShareVersion.Name = "SparkleShareVersion";
this.SparkleShareVersion.Size = new System.Drawing.Size (106, 13);
this.SparkleShareVersion.TabIndex = 1;
this.SparkleShareVersion.Text = "SparkleShareVersion";
//
// SparkleAbout
//
this.AutoScaleDimensions = new System.Drawing.SizeF (6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size (640, 260);
this.Controls.Add (this.SparkleShareVersion);
this.Controls.Add (this.emptyLabel);
this.Controls.Add (this.copyright);
this.Controls.Add (this.version);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SparkleAbout";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "About SparkleShare";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler (this.SparkleAbout_FormClosing);
this.ResumeLayout (false);
this.PerformLayout ();
}
#endregion
private System.Windows.Forms.Label version;
private System.Windows.Forms.Label copyright;
private System.Windows.Forms.Label emptyLabel;
private System.Windows.Forms.Label SparkleShareVersion;
}
}

View file

@ -0,0 +1,85 @@
// SparkleShare, a collaboration and sharing tool.
// Copyright (C) 2010 Hylke Bons (hylkebons@gmail.com)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see (http://www.gnu.org/licenses/).
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Windows.Forms;
using System.Drawing;
namespace SparkleShare {
public partial class SparkleAbout : Form {
public SparkleAboutController Controller = new SparkleAboutController ();
// Short alias for the translations
public static string _(string s)
{
return Program._(s);
}
public SparkleAbout ()
{
InitializeComponent ();
this.BackgroundImage=Icons.about;
this.ClientSize = this.BackgroundImage.Size;
this.Icon = Icons.sparkleshare;
this.SparkleShareVersion.Text = SparkleLib.Defines.VERSION;
this.MaximumSize = this.Size;
this.MinimumSize = this.Size;
this.version.Text = "";
Program.TranslateWinForm (this);
Controller.NewVersionEvent += delegate (string new_version) {
this.version.Invoke((Action)delegate {
this.version.Text = new_version;
});
};
Controller.VersionUpToDateEvent += delegate {
this.version.Invoke((Action)delegate {
this.version.Text = "You are running the latest version.";
});
};
Controller.CheckingForNewVersionEvent += delegate {
this.version.Invoke((Action)delegate {
this.version.Text = "Checking for updates...";
});
};
}
private void SparkleAbout_FormClosing (object sender, FormClosingEventArgs e)
{
if (e.CloseReason != CloseReason.ApplicationExitCall
&& e.CloseReason != CloseReason.TaskManagerClosing
&& e.CloseReason != CloseReason.WindowsShutDown) {
e.Cancel = true;
this.Hide ();
}
}
}
}

View file

@ -0,0 +1,125 @@
<?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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="copyright.Text" xml:space="preserve">
<value>Copyright © 2010-2011 Hylke Bons and others
SparkleShare is Free and Open Source Software. You are free to use, modify, and redistribute it under the terms of the GNU General Public License version 3 or later.</value>
</data>
</root>

View file

@ -0,0 +1,39 @@
// SparkleShare, an instant update workflow to Git.
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using Notifications;
namespace SparkleShare {
public class SparkleBubble : Notification {
public SparkleBubble (string title, string subtext) : base (title, subtext)
{
System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer ();
timer.Tick += delegate { this.Close (); };
timer.Interval = 4500;
timer.Start ();
}
// Checks whether the system allows adding buttons to a notification,
// prevents error messages in Ubuntu.
new public void AddAction (string action, string label, ActionHandler handler)
{
}
}
}

View file

@ -0,0 +1,36 @@
// SparkleShare, a collaboration and sharing tool.
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Windows.Forms;
namespace SparkleShare {
public class SparkleBubbles {
public SparkleBubblesController Controller = new SparkleBubblesController ();
public SparkleBubbles ()
{
Controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) {
SparkleUI.StatusIcon.ShowBalloon(title, subtext, image_path);
};
}
}
}

View file

@ -0,0 +1,235 @@
// SparkleShare, an instant update workflow to Git.
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System.Reflection;
using SparkleLib;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using CefSharp;
using Microsoft.Win32;
namespace SparkleShare {
public class SparkleController : SparkleControllerBase {
private int sshAgentPid;
public override string PluginsPath
{
get
{
return Path.Combine (Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location), "plugins");
}
}
public SparkleController () : base ()
{
}
public override void Initialize ()
{
Settings settings = new Settings ();
BrowserSettings browserSettings = new BrowserSettings ();
if (!CEF.Initialize (settings, browserSettings)) {
Console.WriteLine ("Couldn't initialise CEF");
return;
}
CEF.RegisterScheme ("application", "sparkleshare", new ApplicationSchemeHandlerFactory ());
CEF.RegisterScheme ("application", "file", new FileSchemeHandlerFactory ());
Application.EnableVisualStyles ();
Application.SetCompatibleTextRenderingDefault (false);
// Add msysgit to path, as we cannot asume it is added to the path
// Asume it is installed in @"<exec dir>\msysgit\bin"
string ExecutableDir = Path.GetDirectoryName(Application.ExecutablePath);
string MSysGit = Path.Combine(ExecutableDir, "msysgit");
string newPath = MSysGit + @"\bin" + ";"
+ MSysGit + @"\mingw\bin" + ";"
+ MSysGit + @"\cmd" + ";"
+ System.Environment.ExpandEnvironmentVariables ("%PATH%");
System.Environment.SetEnvironmentVariable ("PATH", newPath);
System.Environment.SetEnvironmentVariable ("PLINK_PROTOCOL", "ssh");
if (String.IsNullOrEmpty (System.Environment.GetEnvironmentVariable ("HOME")))
System.Environment.SetEnvironmentVariable ("HOME", Environment.ExpandEnvironmentVariables ("%HOMEDRIVE%%HOMEPATH%"));
StartSshAgent ();
base.Initialize ();
}
public override string EventLogHTML
{
get
{
string html = Properties.Resources.event_log_html;
html = html.Replace ("<!-- $jquery-url -->", "application://sparkleshare/jquery.js");
return html;
}
}
public override string DayEntryHTML
{
get
{
return Properties.Resources.day_entry_html;
}
}
public override string EventEntryHTML
{
get
{
return Properties.Resources.event_entry_html;
}
}
// Creates a .desktop entry in autostart folder to
// start SparkleShare automatically at login
public override void CreateStartupItem ()
{
}
public override void InstallProtocolHandler()
{
// Get assembly location
string location = System.Reflection.Assembly.GetExecutingAssembly().Location;
string folder = Path.GetDirectoryName(location);
string inviteExe = Path.Combine(folder, "SparkleShareInviteOpen.exe");
// Register protocol handler as explained in
// http://msdn.microsoft.com/en-us/library/ie/aa767914(v=vs.85).aspx
string mainKey = "HKEY_CLASSES_ROOT\\sparkleshare";
Registry.SetValue(mainKey, "", "SparkleShare Invites");
Registry.SetValue(mainKey, "URL Protocol", "");
string iconKey = "HKEY_CLASSES_ROOT\\sparkleshare\\DefaultIcon";
Registry.SetValue(iconKey, "", inviteExe + ",1");
string actionKey = "HKEY_CLASSES_ROOT\\sparkleshare\\shell\\open\\command";
Registry.SetValue(actionKey, "", "\"" + inviteExe + "\" \"%1\"");
}
// Adds the SparkleShare folder to the user's
// list of bookmarked places
public override void AddToBookmarks ()
{
}
// Creates the SparkleShare folder in the user's home folder
public override bool CreateSparkleShareFolder ()
{
if (!Directory.Exists(SparkleConfig.DefaultConfig.FoldersPath))
{
Directory.CreateDirectory(SparkleConfig.DefaultConfig.FoldersPath);
Directory.CreateDirectory(SparkleConfig.DefaultConfig.TmpPath);
SparkleHelpers.DebugInfo("Config", "Created '" + SparkleConfig.DefaultConfig.FoldersPath + "'");
return true;
}
return false;
}
public override void OpenFile(string url)
{
Process process = new Process();
process.StartInfo.Arguments = "\"" + url + "\"";
process.StartInfo.FileName = "start";
process.Start();
}
public override void OpenSparkleShareFolder (string subfolder)
{
Process process = new Process();
process.StartInfo.Arguments = ",/root," + SparkleHelpers.CombineMore(SparkleConfig.DefaultConfig.FoldersPath, subfolder);
process.StartInfo.FileName = "explorer";
process.Start();
}
public override void Quit ()
{
KillSshAgent ();
base.Quit ();
}
private void StartSshAgent ()
{
if (String.IsNullOrEmpty (System.Environment.GetEnvironmentVariable ("SSH_AUTH_SOCK"))) {
Process process = new Process ();
process.StartInfo.FileName = "ssh-agent";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.Start ();
string Output = process.StandardOutput.ReadToEnd ();
process.WaitForExit ();
Match AuthSock = new Regex (@"SSH_AUTH_SOCK=([^;\n\r]*)").Match (Output);
if (AuthSock.Success) {
System.Environment.SetEnvironmentVariable ("SSH_AUTH_SOCK", AuthSock.Groups[1].Value);
}
Match AgentPid = new Regex (@"SSH_AGENT_PID=([^;\n\r]*)").Match (Output);
if (AgentPid.Success) {
Int32.TryParse (AgentPid.Groups [1].Value, out sshAgentPid);
System.Environment.SetEnvironmentVariable ("SSH_AGENT_PID", AgentPid.Groups[1].Value);
SparkleHelpers.DebugInfo ("SSH", "ssh-agent started, PID=" + AgentPid.Groups[1].Value);
}
else {
SparkleHelpers.DebugInfo ("SSH", "ssh-agent started, PID=unknown");
}
}
}
private void KillSshAgent ()
{
if (sshAgentPid != 0) {
// Kill the SSH_AGENT that we started
try {
Process.GetProcessById (sshAgentPid).Kill ();
} catch (ArgumentException) {
SparkleHelpers.DebugInfo ("SSH", "Could not kill the ssh-agent, because the process wasn't running");
}
}
}
}
}

View file

@ -0,0 +1,89 @@
namespace SparkleShare {
partial class SparkleEventLog {
/// <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.WebViewPanel = new System.Windows.Forms.Panel ();
this.panel2 = new System.Windows.Forms.Panel ();
this.combo_box = new System.Windows.Forms.ComboBox ();
this.panel2.SuspendLayout ();
this.SuspendLayout ();
//
// WebViewPanel
//
this.WebViewPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.WebViewPanel.Location = new System.Drawing.Point (0, 44);
this.WebViewPanel.Name = "WebViewPanel";
this.WebViewPanel.Size = new System.Drawing.Size (472, 569);
this.WebViewPanel.TabIndex = 1;
//
// panel2
//
this.panel2.Controls.Add (this.combo_box);
this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
this.panel2.Location = new System.Drawing.Point (0, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size (472, 44);
this.panel2.TabIndex = 0;
//
// combo_box
//
this.combo_box.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.combo_box.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.combo_box.FormattingEnabled = true;
this.combo_box.Location = new System.Drawing.Point (339, 12);
this.combo_box.Name = "combo_box";
this.combo_box.Size = new System.Drawing.Size (121, 21);
this.combo_box.TabIndex = 0;
this.combo_box.SelectedIndexChanged += new System.EventHandler (this.combo_box_SelectedIndexChanged);
//
// SparkleEventLog
//
this.AutoScaleDimensions = new System.Drawing.SizeF (6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size (472, 613);
this.Controls.Add (this.WebViewPanel);
this.Controls.Add (this.panel2);
this.Name = "SparkleEventLog";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Recent Events";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler (this.SparkleEventLog_FormClosing);
this.panel2.ResumeLayout (false);
this.ResumeLayout (false);
}
#endregion
private System.Windows.Forms.Panel WebViewPanel;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.ComboBox combo_box;
}
}

View file

@ -0,0 +1,210 @@
// SparkleShare, a collaboration and sharing tool.
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.InteropServices;
using System.ComponentModel;
using SparkleLib;
using CefSharp;
using System.IO;
using System.Text;
namespace SparkleShare {
public partial class SparkleEventLog : Form, IBeforeResourceLoad {
private readonly CefWebBrowser _browserControl;
private string HTML;
private List<SparkleChangeSet> change_sets;
private string selected_log = null;
// Short alias for the translations
public static string _ (string s)
{
return Program._ (s);
}
public SparkleEventLog ()
{
InitializeComponent ();
Program.TranslateWinForm (this);
this.Icon = Icons.sparkleshare;
this.change_sets = Program.Controller.GetLog (null);
GenerateHTML ();
_browserControl = new CefWebBrowser ("application://sparkleshare/eventlog");
_browserControl.Dock = DockStyle.Fill;
//_browserControl.PropertyChanged += HandleBrowserPropertyChanged;
//_browserControl.ConsoleMessage += HandleConsoleMessage;
_browserControl.BeforeResourceLoadHandler = this;
WebViewPanel.Controls.Add (_browserControl);
UpdateChooser ();
}
public void UpdateChooser ()
{
this.combo_box.Items.Add (_ ("All Folders"));
this.combo_box.Items.Add ("");
foreach (string folder_name in Program.Controller.Folders)
this.combo_box.Items.Add (folder_name);
this.combo_box.SelectedItem = this.combo_box.Items[0];
}
public void UpdateEvents ()
{
UpdateEvents (true);
}
public void UpdateEvents (bool silent)
{
Thread thread = new Thread (new ThreadStart (delegate {
Program.SetUiCulture ();
Stopwatch watch = new Stopwatch ();
watch.Start ();
this.change_sets = Program.Controller.GetLog (this.selected_log);
GenerateHTML ();
watch.Stop ();
// A short delay is less annoying than
// a flashing window
if (watch.ElapsedMilliseconds < 500 && !silent)
Thread.Sleep (500 - (int) watch.ElapsedMilliseconds);
AddHTML ();
}));
thread.Start ();
}
private void GenerateHTML ()
{
HTML = Program.Controller.GetHTMLLog (this.change_sets);
if (HTML == null)
return;
HTML = HTML.Replace ("<!-- $body-font-size -->", this.Font.Size + "px");
HTML = HTML.Replace ("<!-- $day-entry-header-font-size -->", this.Font.Size + "px");
HTML = HTML.Replace ("<!-- $a-color -->", "#0085cf");
HTML = HTML.Replace ("<!-- $a-hover-color -->", "#009ff8");
HTML = HTML.Replace ("<!-- $body-font-family -->", "\"" + this.Font.FontFamily + "\"");
HTML = HTML.Replace ("<!-- $body-color -->", this.ForeColor.ToHex());
HTML = HTML.Replace ("<!-- $body-background-color -->", this.BackColor.ToHex());
HTML = HTML.Replace ("<!-- $day-entry-header-background-color -->", this.BackColor.ToHex());
HTML = HTML.Replace ("<!-- $secondary-font-color -->", this.ForeColor.ToHex());
HTML = HTML.Replace ("<!-- $small-color -->", this.ForeColor.ToHex());
HTML = HTML.Replace ("<!-- $no-buddy-icon-background-image -->",
"application://sparkleshare/avatar-default-32.png");
HTML = HTML.Replace ("<!-- $document-added-background-image -->",
"application://sparkleshare/document-added-12.png");
HTML = HTML.Replace ("<!-- $document-edited-background-image -->",
"application://sparkleshare/document-edited-12.png");
HTML = HTML.Replace ("<!-- $document-deleted-background-image -->",
"application://sparkleshare/document-deleted-12.png");
HTML = HTML.Replace ("<!-- $document-moved-background-image -->",
"application://sparkleshare/document-moved-12.png");
HTML = HTML.Replace("href='" + SparkleConfig.DefaultConfig.FoldersPath, "href='application://file/" + SparkleConfig.DefaultConfig.FoldersPath);
HTML = HTML.Replace ("file://application://sparkleshare/", "application://sparkleshare/");
HTML = HTML.Replace ("file://", "application://file/");
}
private void AddHTML ()
{
try
{
Invoke((Action)delegate
{
_browserControl.Reload();
});
}
catch (InvalidOperationException e)
{
}
}
private void SparkleEventLog_FormClosing (object sender, FormClosingEventArgs e)
{
if (e.CloseReason != CloseReason.ApplicationExitCall
&& e.CloseReason != CloseReason.TaskManagerClosing
&& e.CloseReason != CloseReason.WindowsShutDown) {
e.Cancel = true;
this.Hide ();
}
}
#region IBeforeResourceLoad Members
public void HandleBeforeResourceLoad (CefWebBrowser browserControl, IRequestResponse requestResponse)
{
IRequest request = requestResponse.Request;
Console.WriteLine ("{0} {1}", request.Method, request.Url);
if (request.Url.StartsWith ("application://sparkleshare/eventlog")) {
Stream resourceStream;
if (HTML != null)
resourceStream = new MemoryStream (Encoding.UTF8.GetPreamble ().Concat (Encoding.UTF8.GetBytes (HTML)).ToArray ());
else
resourceStream = new MemoryStream ();
requestResponse.RespondWith (resourceStream, "text/html");
} else if (request.Url.StartsWith ("application://file/")) {
string Filename = request.Url.Substring ("application://file/".Length);
Filename = Uri.UnescapeDataString (Filename);
Filename = Filename.Replace ("/", "\\");
if (Filename.StartsWith(SparkleConfig.DefaultConfig.FoldersPath))
System.Diagnostics.Process.Start (Filename);
}
}
#endregion
private void combo_box_SelectedIndexChanged (object sender, EventArgs e)
{
String SelectedText = this.combo_box.SelectedItem as string;
if (string.IsNullOrEmpty (SelectedText) || SelectedText.Equals (_ ("All Folders")))
this.selected_log = null;
else
this.selected_log = SelectedText;
UpdateEvents (false);
}
}
}

View 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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -0,0 +1,868 @@
namespace SparkleShare {
partial class SparkleSetup {
/// <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() {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SparkleSetup));
this.pictureBox = new System.Windows.Forms.PictureBox();
this.tabControl = new SparkleShare.controls.TablessControl();
this.setupPage = new System.Windows.Forms.TabPage();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.EmailEntry = new System.Windows.Forms.TextBox();
this.buttonNext = new System.Windows.Forms.Button();
this.NameEntry = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.addPage = new System.Windows.Forms.TabPage();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.label4 = new System.Windows.Forms.Label();
this.panel_server_selection = new System.Windows.Forms.Panel();
this.FolderEntry = new SparkleShare.controls.ExampleTextBox();
this.label14 = new System.Windows.Forms.Label();
this.ServerEntry = new SparkleShare.controls.ExampleTextBox();
this.label5 = new System.Windows.Forms.Label();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.buttonSync = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.syncingPage = new System.Windows.Forms.TabPage();
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.flowLayoutPanel4 = new System.Windows.Forms.FlowLayoutPanel();
this.syncFinishButton = new System.Windows.Forms.Button();
this.syncCancelButton = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.syncingProgressBar = new System.Windows.Forms.ProgressBar();
this.label16 = new System.Windows.Forms.Label();
this.label15 = new System.Windows.Forms.Label();
this.errorPage = new System.Windows.Forms.TabPage();
this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();
this.buttonTryAgain = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.finishedPage = new System.Windows.Forms.TabPage();
this.tableLayoutPanel5 = new System.Windows.Forms.TableLayoutPanel();
this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel();
this.buttonOpenFolder = new System.Windows.Forms.Button();
this.buttonFinished = new System.Windows.Forms.Button();
this.label9 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.invitePage = new System.Windows.Forms.TabPage();
this.tableLayoutPanel6 = new System.Windows.Forms.TableLayoutPanel();
this.flowLayoutPanel3 = new System.Windows.Forms.FlowLayoutPanel();
this.InviteAddButton = new System.Windows.Forms.Button();
this.InviteCancelButton = new System.Windows.Forms.Button();
this.InviteFolderEntry = new System.Windows.Forms.TextBox();
this.InviteAddressEntry = new System.Windows.Forms.TextBox();
this.label19 = new System.Windows.Forms.Label();
this.label18 = new System.Windows.Forms.Label();
this.label17 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.tabControl.SuspendLayout();
this.setupPage.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
this.addPage.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
this.syncingPage.SuspendLayout();
this.tableLayoutPanel3.SuspendLayout();
this.flowLayoutPanel4.SuspendLayout();
this.errorPage.SuspendLayout();
this.tableLayoutPanel4.SuspendLayout();
this.finishedPage.SuspendLayout();
this.tableLayoutPanel5.SuspendLayout();
this.flowLayoutPanel2.SuspendLayout();
this.invitePage.SuspendLayout();
this.tableLayoutPanel6.SuspendLayout();
this.flowLayoutPanel3.SuspendLayout();
this.SuspendLayout();
//
// pictureBox
//
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Left;
this.pictureBox.Location = new System.Drawing.Point(0, 0);
this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(150, 396);
this.pictureBox.TabIndex = 1;
this.pictureBox.TabStop = false;
//
// tabControl
//
this.tabControl.Controls.Add(this.setupPage);
this.tabControl.Controls.Add(this.addPage);
this.tabControl.Controls.Add(this.syncingPage);
this.tabControl.Controls.Add(this.errorPage);
this.tabControl.Controls.Add(this.finishedPage);
this.tabControl.Controls.Add(this.invitePage);
this.tabControl.Dock = System.Windows.Forms.DockStyle.Right;
this.tabControl.Location = new System.Drawing.Point(150, 0);
this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0;
this.tabControl.Size = new System.Drawing.Size(514, 396);
this.tabControl.TabIndex = 0;
this.tabControl.TabStop = false;
//
// setupPage
//
this.setupPage.Controls.Add(this.tableLayoutPanel1);
this.setupPage.Location = new System.Drawing.Point(4, 22);
this.setupPage.Name = "setupPage";
this.setupPage.Padding = new System.Windows.Forms.Padding(3);
this.setupPage.Size = new System.Drawing.Size(506, 370);
this.setupPage.TabIndex = 0;
this.setupPage.Text = "Setup";
this.setupPage.UseVisualStyleBackColor = true;
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Controls.Add(this.EmailEntry, 1, 4);
this.tableLayoutPanel1.Controls.Add(this.buttonNext, 1, 6);
this.tableLayoutPanel1.Controls.Add(this.NameEntry, 1, 3);
this.tableLayoutPanel1.Controls.Add(this.label10, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.label13, 0, 4);
this.tableLayoutPanel1.Controls.Add(this.label11, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.label12, 0, 3);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(5);
this.tableLayoutPanel1.RowCount = 7;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 30F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 70F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(500, 364);
this.tableLayoutPanel1.TabIndex = 8;
//
// EmailEntry
//
this.EmailEntry.Dock = System.Windows.Forms.DockStyle.Fill;
this.EmailEntry.Location = new System.Drawing.Point(81, 153);
this.EmailEntry.Name = "EmailEntry";
this.EmailEntry.Size = new System.Drawing.Size(411, 20);
this.EmailEntry.TabIndex = 10;
this.EmailEntry.TextChanged += new System.EventHandler(this.CheckSetupPage);
//
// buttonNext
//
this.buttonNext.Dock = System.Windows.Forms.DockStyle.Right;
this.buttonNext.Enabled = false;
this.buttonNext.Location = new System.Drawing.Point(417, 331);
this.buttonNext.Name = "buttonNext";
this.buttonNext.Size = new System.Drawing.Size(75, 25);
this.buttonNext.TabIndex = 3;
this.buttonNext.Text = "Continue";
this.buttonNext.UseVisualStyleBackColor = true;
this.buttonNext.Click += new System.EventHandler(this.SetupNextClicked);
//
// NameEntry
//
this.NameEntry.Dock = System.Windows.Forms.DockStyle.Fill;
this.NameEntry.Location = new System.Drawing.Point(81, 128);
this.NameEntry.Name = "NameEntry";
this.NameEntry.Size = new System.Drawing.Size(411, 20);
this.NameEntry.TabIndex = 9;
this.NameEntry.TextChanged += new System.EventHandler(this.CheckSetupPage);
//
// label10
//
this.label10.AutoSize = true;
this.tableLayoutPanel1.SetColumnSpan(this.label10, 2);
this.label10.Dock = System.Windows.Forms.DockStyle.Fill;
this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label10.Location = new System.Drawing.Point(8, 5);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(484, 25);
this.label10.TabIndex = 1;
this.label10.Text = "Welcome to SparkleShare!";
//
// label13
//
this.label13.AutoSize = true;
this.label13.Dock = System.Windows.Forms.DockStyle.Fill;
this.label13.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label13.Location = new System.Drawing.Point(8, 150);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(67, 25);
this.label13.TabIndex = 8;
this.label13.Text = "Email:";
this.label13.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label11
//
this.tableLayoutPanel1.SetColumnSpan(this.label11, 2);
this.label11.Dock = System.Windows.Forms.DockStyle.Fill;
this.label11.Location = new System.Drawing.Point(8, 30);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(484, 30);
this.label11.TabIndex = 2;
this.label11.Text = "Before we get started, what\'s your name and email?\r\nDon\'t worry, this information" +
" is only visible to your team members.";
//
// label12
//
this.label12.AutoSize = true;
this.label12.Dock = System.Windows.Forms.DockStyle.Fill;
this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label12.Location = new System.Drawing.Point(8, 125);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(67, 25);
this.label12.TabIndex = 7;
this.label12.Text = "Full Name:";
this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// addPage
//
this.addPage.Controls.Add(this.tableLayoutPanel2);
this.addPage.Location = new System.Drawing.Point(4, 22);
this.addPage.Name = "addPage";
this.addPage.Padding = new System.Windows.Forms.Padding(3);
this.addPage.Size = new System.Drawing.Size(506, 370);
this.addPage.TabIndex = 1;
this.addPage.Text = "Add";
this.addPage.UseVisualStyleBackColor = true;
//
// tableLayoutPanel2
//
this.tableLayoutPanel2.ColumnCount = 2;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.Controls.Add(this.label4, 0, 0);
this.tableLayoutPanel2.Controls.Add(this.panel_server_selection, 0, 2);
this.tableLayoutPanel2.Controls.Add(this.FolderEntry, 1, 5);
this.tableLayoutPanel2.Controls.Add(this.label14, 0, 4);
this.tableLayoutPanel2.Controls.Add(this.ServerEntry, 0, 5);
this.tableLayoutPanel2.Controls.Add(this.label5, 1, 4);
this.tableLayoutPanel2.Controls.Add(this.flowLayoutPanel1, 1, 7);
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.Padding = new System.Windows.Forms.Padding(10);
this.tableLayoutPanel2.RowCount = 8;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 32F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(500, 364);
this.tableLayoutPanel2.TabIndex = 18;
//
// label4
//
this.label4.AutoSize = true;
this.tableLayoutPanel2.SetColumnSpan(this.label4, 2);
this.label4.Dock = System.Windows.Forms.DockStyle.Fill;
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(13, 10);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(474, 30);
this.label4.TabIndex = 0;
this.label4.Text = "Where\'s your project hosted?";
//
// panel_server_selection
//
this.tableLayoutPanel2.SetColumnSpan(this.panel_server_selection, 2);
this.panel_server_selection.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel_server_selection.Location = new System.Drawing.Point(13, 63);
this.panel_server_selection.Name = "panel_server_selection";
this.panel_server_selection.Size = new System.Drawing.Size(474, 171);
this.panel_server_selection.TabIndex = 12;
//
// FolderEntry
//
this.FolderEntry.Dock = System.Windows.Forms.DockStyle.Fill;
this.FolderEntry.ExampleText = "";
this.FolderEntry.ForeColor = System.Drawing.SystemColors.InactiveCaptionText;
this.FolderEntry.Location = new System.Drawing.Point(253, 280);
this.FolderEntry.Name = "FolderEntry";
this.FolderEntry.Size = new System.Drawing.Size(234, 20);
this.FolderEntry.TabIndex = 17;
this.FolderEntry.TextChanged += new System.EventHandler(this.CheckAddPage);
//
// label14
//
this.label14.AutoSize = true;
this.label14.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label14.Location = new System.Drawing.Point(13, 257);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(67, 17);
this.label14.TabIndex = 14;
this.label14.Text = "Address";
//
// ServerEntry
//
this.ServerEntry.Dock = System.Windows.Forms.DockStyle.Fill;
this.ServerEntry.ExampleText = "";
this.ServerEntry.ForeColor = System.Drawing.SystemColors.InactiveCaptionText;
this.ServerEntry.Location = new System.Drawing.Point(13, 280);
this.ServerEntry.Name = "ServerEntry";
this.ServerEntry.Size = new System.Drawing.Size(234, 20);
this.ServerEntry.TabIndex = 16;
this.ServerEntry.TextChanged += new System.EventHandler(this.CheckAddPage);
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label5.Location = new System.Drawing.Point(253, 257);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(101, 17);
this.label5.TabIndex = 15;
this.label5.Text = "Remote Path";
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.Controls.Add(this.buttonSync);
this.flowLayoutPanel1.Controls.Add(this.buttonCancel);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Right;
this.flowLayoutPanel1.Location = new System.Drawing.Point(328, 322);
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(162, 32);
this.flowLayoutPanel1.TabIndex = 18;
//
// buttonSync
//
this.buttonSync.Enabled = false;
this.buttonSync.Location = new System.Drawing.Point(3, 3);
this.buttonSync.Name = "buttonSync";
this.buttonSync.Size = new System.Drawing.Size(75, 25);
this.buttonSync.TabIndex = 9;
this.buttonSync.Text = "Add";
this.buttonSync.UseVisualStyleBackColor = true;
this.buttonSync.Click += new System.EventHandler(this.AddButtonClicked);
//
// buttonCancel
//
this.buttonCancel.Dock = System.Windows.Forms.DockStyle.Right;
this.buttonCancel.Location = new System.Drawing.Point(84, 3);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 25);
this.buttonCancel.TabIndex = 8;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.CancelButtonClicked);
//
// syncingPage
//
this.syncingPage.Controls.Add(this.tableLayoutPanel3);
this.syncingPage.Location = new System.Drawing.Point(4, 22);
this.syncingPage.Name = "syncingPage";
this.syncingPage.Size = new System.Drawing.Size(506, 370);
this.syncingPage.TabIndex = 2;
this.syncingPage.Text = "Syncing";
this.syncingPage.UseVisualStyleBackColor = true;
//
// tableLayoutPanel3
//
this.tableLayoutPanel3.ColumnCount = 1;
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel3.Controls.Add(this.flowLayoutPanel4, 0, 6);
this.tableLayoutPanel3.Controls.Add(this.label6, 0, 0);
this.tableLayoutPanel3.Controls.Add(this.syncingProgressBar, 0, 4);
this.tableLayoutPanel3.Controls.Add(this.label16, 0, 2);
this.tableLayoutPanel3.Controls.Add(this.label15, 0, 1);
this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel3.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
this.tableLayoutPanel3.Padding = new System.Windows.Forms.Padding(10);
this.tableLayoutPanel3.RowCount = 7;
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 15F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 15F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 80F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel3.Size = new System.Drawing.Size(506, 370);
this.tableLayoutPanel3.TabIndex = 6;
//
// flowLayoutPanel4
//
this.flowLayoutPanel4.Controls.Add(this.syncFinishButton);
this.flowLayoutPanel4.Controls.Add(this.syncCancelButton);
this.flowLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Right;
this.flowLayoutPanel4.Location = new System.Drawing.Point(334, 330);
this.flowLayoutPanel4.Margin = new System.Windows.Forms.Padding(0);
this.flowLayoutPanel4.Name = "flowLayoutPanel4";
this.flowLayoutPanel4.Size = new System.Drawing.Size(162, 30);
this.flowLayoutPanel4.TabIndex = 19;
//
// syncFinishButton
//
this.syncFinishButton.Enabled = false;
this.syncFinishButton.Location = new System.Drawing.Point(3, 3);
this.syncFinishButton.Name = "syncFinishButton";
this.syncFinishButton.Size = new System.Drawing.Size(75, 25);
this.syncFinishButton.TabIndex = 9;
this.syncFinishButton.Text = "Finish";
this.syncFinishButton.UseVisualStyleBackColor = true;
//
// syncCancelButton
//
this.syncCancelButton.Dock = System.Windows.Forms.DockStyle.Right;
this.syncCancelButton.Location = new System.Drawing.Point(84, 3);
this.syncCancelButton.Name = "syncCancelButton";
this.syncCancelButton.Size = new System.Drawing.Size(75, 25);
this.syncCancelButton.TabIndex = 8;
this.syncCancelButton.Text = "Cancel";
this.syncCancelButton.UseVisualStyleBackColor = true;
this.syncCancelButton.Click += new System.EventHandler(this.syncCancelClicked);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Dock = System.Windows.Forms.DockStyle.Fill;
this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold);
this.label6.Location = new System.Drawing.Point(13, 10);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(480, 25);
this.label6.TabIndex = 0;
this.label6.Text = "Syncing…";
//
// syncingProgressBar
//
this.syncingProgressBar.Location = new System.Drawing.Point(13, 115);
this.syncingProgressBar.Name = "syncingProgressBar";
this.syncingProgressBar.Size = new System.Drawing.Size(480, 23);
this.syncingProgressBar.TabIndex = 3;
//
// label16
//
this.label16.AutoSize = true;
this.label16.Dock = System.Windows.Forms.DockStyle.Fill;
this.label16.Location = new System.Drawing.Point(13, 50);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(480, 15);
this.label16.TabIndex = 5;
this.label16.Text = "Are you sure its not coffee o\'clock?";
//
// label15
//
this.label15.AutoSize = true;
this.label15.Dock = System.Windows.Forms.DockStyle.Fill;
this.label15.Location = new System.Drawing.Point(13, 35);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(480, 15);
this.label15.TabIndex = 4;
this.label15.Text = "This may take a while.";
//
// errorPage
//
this.errorPage.Controls.Add(this.tableLayoutPanel4);
this.errorPage.Location = new System.Drawing.Point(4, 22);
this.errorPage.Name = "errorPage";
this.errorPage.Size = new System.Drawing.Size(506, 370);
this.errorPage.TabIndex = 3;
this.errorPage.Text = "Error";
this.errorPage.UseVisualStyleBackColor = true;
//
// tableLayoutPanel4
//
this.tableLayoutPanel4.ColumnCount = 1;
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel4.Controls.Add(this.buttonTryAgain, 0, 5);
this.tableLayoutPanel4.Controls.Add(this.label2, 0, 1);
this.tableLayoutPanel4.Controls.Add(this.label3, 0, 3);
this.tableLayoutPanel4.Controls.Add(this.label1, 0, 0);
this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel4.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel4.Name = "tableLayoutPanel4";
this.tableLayoutPanel4.Padding = new System.Windows.Forms.Padding(10);
this.tableLayoutPanel4.RowCount = 6;
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F));
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 70F));
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 80F));
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel4.Size = new System.Drawing.Size(506, 370);
this.tableLayoutPanel4.TabIndex = 4;
//
// buttonTryAgain
//
this.buttonTryAgain.Dock = System.Windows.Forms.DockStyle.Right;
this.buttonTryAgain.Location = new System.Drawing.Point(418, 333);
this.buttonTryAgain.Name = "buttonTryAgain";
this.buttonTryAgain.Size = new System.Drawing.Size(75, 24);
this.buttonTryAgain.TabIndex = 3;
this.buttonTryAgain.Text = "Try Again…";
this.buttonTryAgain.UseVisualStyleBackColor = true;
this.buttonTryAgain.Click += new System.EventHandler(this.buttonTryAgain_Click);
//
// label2
//
this.label2.Dock = System.Windows.Forms.DockStyle.Fill;
this.label2.Location = new System.Drawing.Point(13, 30);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(480, 40);
this.label2.TabIndex = 1;
this.label2.Text = "We don\'t know exactly what the problem is, but we can try to help you pinpoint it" +
".";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label3
//
this.label3.Dock = System.Windows.Forms.DockStyle.Fill;
this.label3.Location = new System.Drawing.Point(13, 108);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(480, 70);
this.label3.TabIndex = 2;
this.label3.Text = resources.GetString("label3.Text");
//
// label1
//
this.label1.AutoSize = true;
this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold);
this.label1.Location = new System.Drawing.Point(13, 10);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(480, 20);
this.label1.TabIndex = 0;
this.label1.Text = "Something went wrong";
//
// finishedPage
//
this.finishedPage.Controls.Add(this.tableLayoutPanel5);
this.finishedPage.Location = new System.Drawing.Point(4, 22);
this.finishedPage.Name = "finishedPage";
this.finishedPage.Size = new System.Drawing.Size(506, 370);
this.finishedPage.TabIndex = 4;
this.finishedPage.Text = "Finished";
this.finishedPage.UseVisualStyleBackColor = true;
//
// tableLayoutPanel5
//
this.tableLayoutPanel5.ColumnCount = 1;
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel5.Controls.Add(this.flowLayoutPanel2, 0, 3);
this.tableLayoutPanel5.Controls.Add(this.label9, 0, 1);
this.tableLayoutPanel5.Controls.Add(this.label8, 0, 0);
this.tableLayoutPanel5.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel5.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel5.Name = "tableLayoutPanel5";
this.tableLayoutPanel5.Padding = new System.Windows.Forms.Padding(10);
this.tableLayoutPanel5.RowCount = 4;
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 15F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel5.Size = new System.Drawing.Size(506, 370);
this.tableLayoutPanel5.TabIndex = 4;
//
// flowLayoutPanel2
//
this.flowLayoutPanel2.Controls.Add(this.buttonOpenFolder);
this.flowLayoutPanel2.Controls.Add(this.buttonFinished);
this.flowLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Right;
this.flowLayoutPanel2.Location = new System.Drawing.Point(334, 330);
this.flowLayoutPanel2.Margin = new System.Windows.Forms.Padding(0);
this.flowLayoutPanel2.Name = "flowLayoutPanel2";
this.flowLayoutPanel2.Size = new System.Drawing.Size(162, 30);
this.flowLayoutPanel2.TabIndex = 0;
//
// buttonOpenFolder
//
this.buttonOpenFolder.Location = new System.Drawing.Point(3, 3);
this.buttonOpenFolder.Name = "buttonOpenFolder";
this.buttonOpenFolder.Size = new System.Drawing.Size(75, 23);
this.buttonOpenFolder.TabIndex = 0;
this.buttonOpenFolder.Text = "Open Folder";
this.buttonOpenFolder.UseVisualStyleBackColor = true;
this.buttonOpenFolder.Click += new System.EventHandler(this.buttonOpenFolder_Click);
//
// buttonFinished
//
this.buttonFinished.Location = new System.Drawing.Point(84, 3);
this.buttonFinished.Name = "buttonFinished";
this.buttonFinished.Size = new System.Drawing.Size(75, 23);
this.buttonFinished.TabIndex = 1;
this.buttonFinished.Text = "Finish";
this.buttonFinished.UseVisualStyleBackColor = true;
this.buttonFinished.Click += new System.EventHandler(this.buttonFinished_Click);
//
// label9
//
this.label9.Location = new System.Drawing.Point(13, 35);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(307, 15);
this.label9.TabIndex = 3;
this.label9.Text = "Access the files from your SparkleShare folder.";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold);
this.label8.Location = new System.Drawing.Point(13, 10);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(227, 20);
this.label8.TabIndex = 2;
this.label8.Text = "Project successfully added!";
//
// invitePage
//
this.invitePage.Controls.Add(this.tableLayoutPanel6);
this.invitePage.Location = new System.Drawing.Point(4, 22);
this.invitePage.Name = "invitePage";
this.invitePage.Padding = new System.Windows.Forms.Padding(3);
this.invitePage.Size = new System.Drawing.Size(506, 370);
this.invitePage.TabIndex = 5;
this.invitePage.Text = "Invite";
this.invitePage.UseVisualStyleBackColor = true;
//
// tableLayoutPanel6
//
this.tableLayoutPanel6.ColumnCount = 2;
this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel6.Controls.Add(this.flowLayoutPanel3, 1, 6);
this.tableLayoutPanel6.Controls.Add(this.InviteFolderEntry, 1, 4);
this.tableLayoutPanel6.Controls.Add(this.InviteAddressEntry, 1, 3);
this.tableLayoutPanel6.Controls.Add(this.label19, 0, 4);
this.tableLayoutPanel6.Controls.Add(this.label18, 0, 3);
this.tableLayoutPanel6.Controls.Add(this.label17, 0, 1);
this.tableLayoutPanel6.Controls.Add(this.label7, 0, 0);
this.tableLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel6.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel6.Name = "tableLayoutPanel6";
this.tableLayoutPanel6.RowCount = 7;
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 30F));
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 70F));
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 32F));
this.tableLayoutPanel6.Size = new System.Drawing.Size(500, 364);
this.tableLayoutPanel6.TabIndex = 0;
//
// flowLayoutPanel3
//
this.flowLayoutPanel3.Controls.Add(this.InviteAddButton);
this.flowLayoutPanel3.Controls.Add(this.InviteCancelButton);
this.flowLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Right;
this.flowLayoutPanel3.Location = new System.Drawing.Point(338, 331);
this.flowLayoutPanel3.Margin = new System.Windows.Forms.Padding(0);
this.flowLayoutPanel3.Name = "flowLayoutPanel3";
this.flowLayoutPanel3.Size = new System.Drawing.Size(162, 33);
this.flowLayoutPanel3.TabIndex = 19;
//
// InviteAddButton
//
this.InviteAddButton.Enabled = false;
this.InviteAddButton.Location = new System.Drawing.Point(3, 3);
this.InviteAddButton.Name = "InviteAddButton";
this.InviteAddButton.Size = new System.Drawing.Size(75, 25);
this.InviteAddButton.TabIndex = 9;
this.InviteAddButton.Text = "Add";
this.InviteAddButton.UseVisualStyleBackColor = true;
this.InviteAddButton.Click += new System.EventHandler(this.InviteAddButtonClicked);
//
// InviteCancelButton
//
this.InviteCancelButton.Dock = System.Windows.Forms.DockStyle.Right;
this.InviteCancelButton.Location = new System.Drawing.Point(84, 3);
this.InviteCancelButton.Name = "InviteCancelButton";
this.InviteCancelButton.Size = new System.Drawing.Size(75, 25);
this.InviteCancelButton.TabIndex = 8;
this.InviteCancelButton.Text = "Cancel";
this.InviteCancelButton.UseVisualStyleBackColor = true;
this.InviteCancelButton.Click += new System.EventHandler(this.InviteCancelButtonClicked);
//
// InviteFolderEntry
//
this.InviteFolderEntry.Dock = System.Windows.Forms.DockStyle.Fill;
this.InviteFolderEntry.Location = new System.Drawing.Point(93, 144);
this.InviteFolderEntry.Name = "InviteFolderEntry";
this.InviteFolderEntry.ReadOnly = true;
this.InviteFolderEntry.Size = new System.Drawing.Size(404, 20);
this.InviteFolderEntry.TabIndex = 11;
//
// InviteAddressEntry
//
this.InviteAddressEntry.Dock = System.Windows.Forms.DockStyle.Fill;
this.InviteAddressEntry.Location = new System.Drawing.Point(93, 119);
this.InviteAddressEntry.Name = "InviteAddressEntry";
this.InviteAddressEntry.ReadOnly = true;
this.InviteAddressEntry.Size = new System.Drawing.Size(404, 20);
this.InviteAddressEntry.TabIndex = 10;
//
// label19
//
this.label19.AutoSize = true;
this.label19.Dock = System.Windows.Forms.DockStyle.Fill;
this.label19.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label19.Location = new System.Drawing.Point(3, 141);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(84, 25);
this.label19.TabIndex = 9;
this.label19.Text = "Remote Path:";
this.label19.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label18
//
this.label18.AutoSize = true;
this.label18.Dock = System.Windows.Forms.DockStyle.Fill;
this.label18.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label18.Location = new System.Drawing.Point(3, 116);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(84, 25);
this.label18.TabIndex = 8;
this.label18.Text = "Address:";
this.label18.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label17
//
this.tableLayoutPanel6.SetColumnSpan(this.label17, 2);
this.label17.Dock = System.Windows.Forms.DockStyle.Fill;
this.label17.Location = new System.Drawing.Point(3, 25);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(494, 20);
this.label17.TabIndex = 3;
this.label17.Text = "Do you want to add this project to SparkleShare?";
//
// label7
//
this.label7.AutoSize = true;
this.tableLayoutPanel6.SetColumnSpan(this.label7, 2);
this.label7.Dock = System.Windows.Forms.DockStyle.Fill;
this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label7.Location = new System.Drawing.Point(3, 0);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(494, 25);
this.label7.TabIndex = 2;
this.label7.Text = "You\'ve received an invite!";
//
// SparkleSetup
//
this.ClientSize = new System.Drawing.Size(664, 396);
this.Controls.Add(this.tabControl);
this.Controls.Add(this.pictureBox);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "SparkleSetup";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "SparkleShare Setup";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SparkleSetup_FormClosing);
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.tabControl.ResumeLayout(false);
this.setupPage.ResumeLayout(false);
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.addPage.ResumeLayout(false);
this.tableLayoutPanel2.ResumeLayout(false);
this.tableLayoutPanel2.PerformLayout();
this.flowLayoutPanel1.ResumeLayout(false);
this.syncingPage.ResumeLayout(false);
this.tableLayoutPanel3.ResumeLayout(false);
this.tableLayoutPanel3.PerformLayout();
this.flowLayoutPanel4.ResumeLayout(false);
this.errorPage.ResumeLayout(false);
this.tableLayoutPanel4.ResumeLayout(false);
this.tableLayoutPanel4.PerformLayout();
this.finishedPage.ResumeLayout(false);
this.tableLayoutPanel5.ResumeLayout(false);
this.tableLayoutPanel5.PerformLayout();
this.flowLayoutPanel2.ResumeLayout(false);
this.invitePage.ResumeLayout(false);
this.tableLayoutPanel6.ResumeLayout(false);
this.tableLayoutPanel6.PerformLayout();
this.flowLayoutPanel3.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private SparkleShare.controls.TablessControl tabControl;
private System.Windows.Forms.TabPage setupPage;
private System.Windows.Forms.TabPage addPage;
private System.Windows.Forms.TabPage syncingPage;
private System.Windows.Forms.TabPage errorPage;
private System.Windows.Forms.TabPage finishedPage;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button buttonSync;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.PictureBox pictureBox;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.ProgressBar syncingProgressBar;
private System.Windows.Forms.Button buttonTryAgain;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Button buttonFinished;
private System.Windows.Forms.Button buttonOpenFolder;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Panel panel_server_selection;
private System.Windows.Forms.TextBox EmailEntry;
private System.Windows.Forms.TextBox NameEntry;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label14;
private SparkleShare.controls.ExampleTextBox FolderEntry;
private SparkleShare.controls.ExampleTextBox ServerEntry;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Button buttonNext;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel5;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2;
private System.Windows.Forms.TabPage invitePage;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel6;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label19;
private System.Windows.Forms.Label label18;
private System.Windows.Forms.TextBox InviteFolderEntry;
private System.Windows.Forms.TextBox InviteAddressEntry;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel3;
private System.Windows.Forms.Button InviteAddButton;
private System.Windows.Forms.Button InviteCancelButton;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel4;
private System.Windows.Forms.Button syncFinishButton;
private System.Windows.Forms.Button syncCancelButton;
}
}

View file

@ -0,0 +1,294 @@
// SparkleShare, a collaboration and sharing tool.
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General private License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General private License for more details.
//
// You should have received a copy of the GNU General private License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
using System.Timers;
using System.Collections.Generic;
using System.Threading;
using System.Windows.Forms;
using System.Drawing;
namespace SparkleShare {
public partial class SparkleSetup : Form {
public SparkleSetupController Controller = new SparkleSetupController ();
private TreeView treeView;
// Short alias for the translations
public static string _ (string s) {
return Program._ (s);
}
public SparkleSetup () {
InitializeComponent ();
Program.TranslateWinForm (this);
pictureBox.Image = Icons.side_splash;
this.Icon = Icons.sparkleshare;
Controller.HideWindowEvent += delegate
{
this.Hide();
};
Controller.ShowWindowEvent += delegate
{
this.Show();
};
Controller.ChangePageEvent += delegate (PageType type, string [] warnings) {
tabControl.SafeInvoke ((Action)delegate {
switch (type) {
case PageType.Setup:
tabControl.SelectedIndex = 0;
NameEntry.Text = Controller.GuessedUserName;
EmailEntry.Text = Controller.GuessedUserEmail;
Show();
Controller.CheckSetupPage(NameEntry.Text, EmailEntry.Text);
break;
case PageType.Add:
tabControl.SelectedIndex = 1;
// Add plugins to tree
// ===================
// Check whether the treeView is already created
// If it is dispose it and start over
if (treeView != null) {
treeView.Dispose();
}
// Set up the treeview
ImageList imageList = new ImageList ();
imageList.ImageSize = new Size (24, 24);
treeView = new TreeView ();
treeView.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawText;
treeView.FullRowSelect = true;
treeView.ImageIndex = 0;
treeView.Indent = 35;
treeView.HideSelection = false;
treeView.ItemHeight = 40;
TreeNode [] nodes = new TreeNode [Controller.Plugins.Count];
for (int i = 0; i < Controller.Plugins.Count; i++) {
nodes [i] = new TreeNode (Controller.Plugins [i].Name + ";" + Controller.Plugins [i].Description);
nodes [i].ImageIndex = i;
nodes [i].SelectedImageIndex = i;
nodes [i].Tag = Controller.Plugins [i].Name;
imageList.Images.Add (Image.FromFile (Controller.Plugins [i].ImagePath));
}
treeView.Nodes.AddRange (nodes);
treeView.ImageList = imageList;
treeView.ShowLines = false;
treeView.ShowRootLines = false;
treeView.Size = new System.Drawing.Size (panel_server_selection.Size.Width,
panel_server_selection.Size.Height);
panel_server_selection.Controls.Add (treeView);
// Finished adding and populating tree
// Select first node
treeView.SelectedNode = treeView.Nodes[0];
treeView.Select();
Controller.SelectedPluginChanged(0);
treeView.AfterSelect += new TreeViewEventHandler(CheckTreeNode);
Show ();
Controller.CheckAddPage(ServerEntry.Text, FolderEntry.Text, 1);
break;
case PageType.Invite:
tabControl.SelectedIndex = 5;
InviteAddressEntry.Text = Controller.PendingInvite.Address;
InviteFolderEntry.Text = Controller.PendingInvite.RemotePath;
Show();
break;
case PageType.Syncing:
tabControl.SelectedIndex = 2;
Show();
break;
case PageType.Error:
tabControl.SelectedIndex = 3;
label3.Text = "First, have you tried turning it off and on again?\n\n" +
Controller.PreviousUrl + " is the address we've compiled. Does this look alright?\n\n" +
"The host needs to know who you are. Have you uploaded the key that sits in your SparkleShare folder?";
Show ();
break;
case PageType.Finished:
tabControl.SelectedIndex = 4;
Show ();
break;
case PageType.Tutorial:
// Do nothing in tutorial by now
Controller.TutorialSkipped();;
break;
default:
throw new NotImplementedException ("unknown PageType");
}
});
};
Controller.UpdateSetupContinueButtonEvent += new SparkleSetupController.UpdateSetupContinueButtonEventHandler(UpdateSetupContinueButtonEvent);
Controller.ChangeAddressFieldEvent += new SparkleSetupController.ChangeAddressFieldEventHandler(ChangeAddressFieldEvent);
Controller.ChangePathFieldEvent += new SparkleSetupController.ChangePathFieldEventHandler(ChangePathFieldEvent);
Controller.UpdateAddProjectButtonEvent += new SparkleSetupController.UpdateAddProjectButtonEventHandler(UpdateAddProjectButtonEvent);
Controller.UpdateProgressBarEvent += new SparkleSetupController.UpdateProgressBarEventHandler(UpdateProgressBarEvent);
}
private void SparkleSetup_FormClosing (object sender, FormClosingEventArgs e) {
if (e.CloseReason != CloseReason.ApplicationExitCall
&& e.CloseReason != CloseReason.TaskManagerClosing
&& e.CloseReason != CloseReason.WindowsShutDown) {
e.Cancel = true;
this.Hide ();
}
}
#region Things for "Setup" page
private void SetupNextClicked(object sender, EventArgs e)
{
Controller.SetupPageCompleted(NameEntry.Text, EmailEntry.Text);
}
private void CheckSetupPage(object sender, EventArgs e)
{
Controller.CheckSetupPage(NameEntry.Text, EmailEntry.Text);
}
void UpdateSetupContinueButtonEvent(bool button_enabled)
{
buttonNext.Enabled = button_enabled;
}
#endregion
#region Things for "Add" page
void ChangeAddressFieldEvent(string text, string example_text, FieldState state)
{
ServerEntry.Text = text;
ServerEntry.Enabled = state == FieldState.Enabled;
ServerEntry.ExampleText = example_text;
}
void ChangePathFieldEvent(string text, string example_text, FieldState state)
{
FolderEntry.Text = text;
FolderEntry.Enabled = state == FieldState.Enabled;
FolderEntry.ExampleText = example_text;
}
private void CheckTreeNode(object sender, EventArgs e)
{
Controller.SelectedPluginChanged(treeView.SelectedNode.Index);
}
private void CancelButtonClicked (object sender, EventArgs e) {
Controller.PageCancelled();
}
private void AddButtonClicked(object sender, EventArgs e)
{
Controller.AddPageCompleted(ServerEntry.Text, FolderEntry.Text);
}
void UpdateAddProjectButtonEvent(bool button_enabled)
{
buttonSync.Enabled = button_enabled;
}
private void CheckAddPage(object sender, EventArgs e)
{
Controller.CheckAddPage(ServerEntry.Text, FolderEntry.Text, treeView.SelectedNode.Index);
}
#endregion
#region Things for "Invite" page
private void InviteAddButtonClicked(object sender, EventArgs e)
{
Controller.InvitePageCompleted();
}
private void InviteCancelButtonClicked(object sender, EventArgs e)
{
Controller.PageCancelled();
}
#endregion
#region Things for "Syncing" page
private void syncCancelClicked(object sender, EventArgs e)
{
Controller.SyncingCancelled();
}
void UpdateProgressBarEvent(double percentage)
{
syncingProgressBar.Value = (int)percentage;
}
#endregion
#region Things for "Error" page
private void buttonTryAgain_Click(object sender, EventArgs e)
{
Controller.ErrorPageCompleted();
}
#endregion
#region Thigngs for "Finish" page
private void buttonFinished_Click (object sender, EventArgs e) {
Controller.FinishPageCompleted();
}
private void buttonOpenFolder_Click (object sender, EventArgs e) {
Controller.OpenFolderClicked();
}
#endregion
}
}
public class TreeView : System.Windows.Forms.TreeView {
protected override void OnDrawNode (DrawTreeNodeEventArgs e) {
e.Graphics.DrawString (e.Node.Text.Split (';') [0], new Font (Font.SystemFontName, 13),
new SolidBrush (Color.Black), e.Bounds.X, e.Bounds.Y);
e.Graphics.DrawString (e.Node.Text.Split (';') [1], new Font (Font.SystemFontName, 9),
new SolidBrush (Color.Black), e.Bounds.X + 10, e.Bounds.Y + 15);
}
}
public class TreeNode : System.Windows.Forms.TreeNode {
public TreeNode (string text) {
this.Text = text;
}
}

View 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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="label3.Text" xml:space="preserve">
<value>First, have you tried turning it off and on again? is the address we've compiled {Controller.SyncingFolder} from the information you entered. Does this look correct?
The host needs to know who you are. Have you uploaded the key that sits in your SparkleShare folder?
</value>
</data>
</root>

View file

@ -0,0 +1,422 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<ProjectGuid>{728483AA-E34B-4441-BF2C-C8BC2901E4E0}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AssemblyName>SparkleShare</AssemblyName>
<SchemaVersion>2.0</SchemaVersion>
<RootNamespace>SparkleShare</RootNamespace>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<ApplicationIcon>..\..\data\icons\sparkleshare.ico</ApplicationIcon>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\bin</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\bin</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Reference Include="CefSharp, Version=0.3.4006.34354, Culture=neutral, processorArchitecture=x86">
<HintPath>..\..\bin\CefSharp.dll</HintPath>
</Reference>
<Reference Include="Gettext.Cs, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\tools\gettext-cs-utils\Gettext.CsUtils\Core\Gettext.Cs\bin\Release\Gettext.Cs.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\SparkleLib\windows\GlobalAssemblyInfo.cs">
<Link>GlobalAssemblyInfo.cs</Link>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>GlobalAssemblyInfo.tt</DependentUpon>
</Compile>
<Compile Include="..\SparkleBubblesController.cs">
<Link>SparkleBubblesController.cs</Link>
</Compile>
<Compile Include="..\SparkleControllerBase.cs">
<Link>SparkleControllerBase.cs</Link>
</Compile>
<Compile Include="..\SparkleExtensions.cs">
<Link>SparkleExtensions.cs</Link>
</Compile>
<Compile Include="..\SparkleInvite.cs">
<Link>SparkleInvite.cs</Link>
</Compile>
<Compile Include="..\SparkleOptions.cs">
<Link>SparkleOptions.cs</Link>
</Compile>
<Compile Include="..\SparklePlugin.cs">
<Link>SparklePlugin.cs</Link>
</Compile>
<Compile Include="..\SparkleStatusIconController.cs">
<Link>SparkleStatusIconController.cs</Link>
</Compile>
<Compile Include="ApplicationSchemeHandler.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="controls\ExampleTextBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="FileSchemeHandler.cs" />
<Compile Include="Icons.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Icons.resx</DependentUpon>
</Compile>
<Compile Include="Notification.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Notification.designer.cs">
<DependentUpon>Notification.cs</DependentUpon>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="SparkleAbout.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SparkleAbout.Designer.cs">
<DependentUpon>SparkleAbout.cs</DependentUpon>
</Compile>
<Compile Include="SparkleBubble.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="..\SparkleSetupController.cs" />
<Compile Include="..\SparkleUI.cs" />
<Compile Include="..\SparkleAboutController.cs" />
<Compile Include="SparkleBubbles.cs" />
<Compile Include="SparkleController.cs" />
<Compile Include="SparkleEventLog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SparkleEventLog.Designer.cs">
<DependentUpon>SparkleEventLog.cs</DependentUpon>
</Compile>
<Compile Include="SparkleSetup.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SparkleSetup.Designer.cs">
<DependentUpon>SparkleSetup.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="SparkleStatusIcon.cs" />
<Compile Include="SparkleUIHelpers.cs" />
<Compile Include="controls\TablessControl.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Strings.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Strings.tt</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\SparkleLib\Windows\SparkleLib.csproj">
<Project>{2C914413-B31C-4362-93C7-1AE34F09112A}</Project>
<Name>SparkleLib</Name>
</ProjectReference>
</ItemGroup>
<ProjectExtensions>
<MonoDevelop>
<Properties InternalTargetFrameworkVersion="3.5">
<MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="true" RelativeMakefileName="Makefile.am">
<BuildFilesVar Sync="true" Name="SOURCES" />
<DeployFilesVar />
<ResourcesVar />
<OthersVar />
<GacRefVar />
<AsmRefVar />
<ProjectRefVar />
</MonoDevelop.Autotools.MakefileInfo>
</Properties>
</MonoDevelop>
<VisualStudio />
</ProjectExtensions>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
<Visible>False</Visible>
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
<Visible>False</Visible>
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
<Service Include="{B4F97281-0DBD-4835-9ED8-7DFB966E87FF}" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\SparkleLib\windows\GlobalAssemblyInfo.tt">
<Link>GlobalAssemblyInfo.tt</Link>
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>GlobalAssemblyInfo.cs</LastGenOutput>
</None>
</ItemGroup>
<PropertyGroup>
<PreBuildEvent>$(ProjectDir)transform_tt.cmd</PreBuildEvent>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Icons.resx">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Icons.tt</DependentUpon>
<SubType>Designer</SubType>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Icons.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Notification.resx">
<DependentUpon>Notification.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="SparkleAbout.resx">
<DependentUpon>SparkleAbout.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="SparkleEventLog.resx">
<DependentUpon>SparkleEventLog.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="SparkleSetup.resx">
<DependentUpon>SparkleSetup.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="Icons.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Icons.resx</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="..\..\data\plugins\bitbucket.png">
<Link>plugins\bitbucket.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\data\plugins\github.png">
<Link>plugins\github.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\data\plugins\gitorious.png">
<Link>plugins\gitorious.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\data\plugins\gnome.png">
<Link>plugins\gnome.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\data\plugins\own-server.png">
<Link>plugins\own-server.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="..\..\data\plugins\bitbucket.xml">
<Link>plugins\bitbucket.xml</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\data\plugins\github.xml">
<Link>plugins\github.xml</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\data\plugins\gitorious.xml">
<Link>plugins\gitorious.xml</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\data\plugins\gnome.xml">
<Link>plugins\gnome.xml</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\data\plugins\own-server.xml">
<Link>plugins\own-server.xml</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\ar.po">
<Link>po\ar.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\bg.po">
<Link>po\bg.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\ca.po">
<Link>po\ca.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\cs_CZ.po">
<Link>po\cs_CZ.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\da.po">
<Link>po\da.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\de.po">
<Link>po\de.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\el.po">
<Link>po\el.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\eo.po">
<Link>po\eo.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\es.po">
<Link>po\es.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\fi.po">
<Link>po\fi.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\fr.po">
<Link>po\fr.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\he.po">
<Link>po\he.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\hu.po">
<Link>po\hu.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\it.po">
<Link>po\it.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\ja.po">
<Link>po\ja.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\nl.po">
<Link>po\nl.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\nn_NO.po">
<Link>po\nn_NO.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\no_NO.po">
<Link>po\no_NO.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\pl.po">
<Link>po\pl.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\pt_BR.po">
<Link>po\pt_BR.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\ru.po">
<Link>po\ru.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\sk.po">
<Link>po\sk.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\sl.po">
<Link>po\sl.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\sr_RS.po">
<Link>po\sr_RS.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\sv.po">
<Link>po\sv.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\te.po">
<Link>po\te.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\uk.po">
<Link>po\uk.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\zh_CN.po">
<Link>po\zh_CN.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\po\zh_TW.po">
<Link>po\zh_TW.po</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Strings.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Strings.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="..\..\data\icons\sparkleshare.ico" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkleShare", "SparkleShare.csproj", "{728483AA-E34B-4441-BF2C-C8BC2901E4E0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkleLib", "..\..\SparkleLib\windows\SparkleLib.csproj", "{2C914413-B31C-4362-93C7-1AE34F09112A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkleShareInviteOpen", "SparkleShareInviteOpen\SparkleShareInviteOpen.csproj", "{1DB5492D-B897-4A5E-8DD7-175EC65F52F2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Release|Any CPU.Build.0 = Release|Any CPU
{2C914413-B31C-4362-93C7-1AE34F09112A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C914413-B31C-4362-93C7-1AE34F09112A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C914413-B31C-4362-93C7-1AE34F09112A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C914413-B31C-4362-93C7-1AE34F09112A}.Release|Any CPU.Build.0 = Release|Any CPU
{1DB5492D-B897-4A5E-8DD7-175EC65F52F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DB5492D-B897-4A5E-8DD7-175EC65F52F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DB5492D-B897-4A5E-8DD7-175EC65F52F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DB5492D-B897-4A5E-8DD7-175EC65F52F2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = SparkleShare.csproj
outputpath = bin
name = SparkleShare
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,99 @@
<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Product Name='SparkleShare' Id='184950D5-67F6-4D06-9717-7E2F1607A7B0' UpgradeCode='D3DF1D99-87F5-47A7-A349-863DD6E4B73A'
Language='1033' Codepage='1252' Version='0.8.1' Manufacturer='sparkleshare.org'>
<Package Id='*' Keywords='Installer' Description="SparkleShare Installer"
Comments='This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.' Manufacturer='sparkleshare.org'
InstallerVersion='100' Languages='1033' Compressed='yes' SummaryCodepage='1252' />
<Media Id='1' Cabinet='SparkleShare.cab' EmbedCab='yes' DiskPrompt='SparkleShare CAB' />
<Property Id='DiskPrompt' Value="sparkleshare.org Bundle CAB Installation" />
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id='sparkleshareDotOrgDir' Name='sparkleshare.org'>
<Directory Id='INSTALLDIR' Name='SparkleShare'>
<Component Id='SparkleShare.exe' Guid='0DA582D5-4ABE-4251-9F62-E7DEA76F10E1'>
<File Id='SparkleShare.exe' Name='SparkleShare.exe' Source='!(wix.root)\bin\SparkleShare.exe' KeyPath='yes' DiskId='1' />
</Component>
<Component Id='SparkleShareInviteOpen.exe' Guid='0DA582D5-4ABE-4251-9F62-E7DEA76F28E1'>
<File Id='SparkleShareInviteOpen.exe' Name='SparkleShareInviteOpen.exe' Source='!(wix.root)\bin\SparkleShareInviteOpen.exe' DiskId='1' />
</Component>
<Component Id='Libraries' Guid='0DA692D5-4DBE-4251-9F62-E7C1A76F10E1'>
<File Id='CefSharp.dll' Name='CefSharp.dll' Source='!(wix.root)\bin\CefSharp.dll' DiskId='1' />
<File Id='Gettext.Cs.dll' Name='Gettext.Cs.dll' Source='!(wix.root)\bin\Gettext.Cs.dll' DiskId='1' />
<File Id='SparkleLib.dll' Name='SparkleLib.dll' Source='!(wix.root)\bin\SparkleLib.dll' DiskId='1' />
<File Id='avcodec52.dll' Name='avcodec-52.dll' Source='!(wix.root)\bin\avcodec-52.dll' DiskId='1' />
<File Id='avformat52.dll' Name='avformat-52.dll' Source='!(wix.root)\bin\avformat-52.dll' DiskId='1' />
<File Id='avutil50.dll' Name='avutil-50.dll' Source='!(wix.root)\bin\avutil-50.dll' DiskId='1' />
<File Id='icudt42.dll' Name='icudt42.dll' Source='!(wix.root)\bin\icudt42.dll' DiskId='1' />
<File Id='libcef.dll' Name='libcef.dll' Source='!(wix.root)\bin\libcef.dll' DiskId='1' />
<File Id='sparkleshare.ico' Name='sparkleshare.ico' Source='!(wix.root)\data\icons\sparkleshare.ico' DiskId='1' />
</Component>
<Directory Id='MSYSGIT_DIR' Name='msysgit'>
</Directory>
<Directory Id='PO_DIR' Name='po'>
</Directory>
<Directory Id='PLUGINS_DIR' Name='plugins'>
</Directory>
</Directory>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="SparkleShare">
<Component Id="ApplicationShortcut" Guid="468550D5-67F6-4D06-97A2-7E2F1607A7B0">
<Shortcut Id="ApplicationStartMenuShortcut"
Name="SparkleShare"
Description="Collaboration and sharing tool that is designed to keep things simple"
Target="[INSTALLDIR]SparkleShare.exe"
WorkingDirectory="INSTALLDIR"/>
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\SparkleShare" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</Directory>
</Directory>
<Component Id="Autostart" Guid="468321D5-6AB6-248E-97A2-7E2F162447B0">
<RegistryValue Root="HKMU" Key="Software\Microsoft\Windows\CurrentVersion\Run" Name="SparkleShare" Type="string" Value="[INSTALLDIR]SparkleShare.exe" KeyPath="yes" />
</Component>
</Directory>
<Feature Id='SparkleShareFeature' Title='SparkleShare' Description='This is the SparkleShare executables.' Level='1' AllowAdvertise='no'>
<ComponentRef Id="SparkleShare.exe" />
<ComponentRef Id="SparkleShareInviteOpen.exe" />
<ComponentRef Id="Libraries" />
<ComponentRef Id="ApplicationShortcut" />
<ComponentRef Id="Autostart" />
<ComponentGroupRef Id='msysGitComponentGroup' />
<ComponentGroupRef Id='poComponentGroup' />
<ComponentGroupRef Id='pluginsComponentGroup' />
</Feature>
<UI>
<UIRef Id="WixUI_InstallDir" />
<!-- <Publish Dialog="ExitDialog"
Control="Finish"
Event="DoAction"
Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish> -->
</UI>
<!-- <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch SparkleShare" /> -->
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
<WixVariable Id="WixUILicenseRtf" Value="..\..\LICENSE.rtf" />
<WixVariable Id="WixUIBannerBmp" Value="..\..\data\install\bannrbmp.bmp" />
<WixVariable Id="WixUIDialogBmp" Value="..\..\data\install\dlgbmp.bmp" />
<Property Id="WixShellExecTarget" Value="[#SparkleShare.exe]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
<InstallExecuteSequence>
<Custom Action="LaunchApplication" After="InstallFinalize">Not Installed</Custom>
</InstallExecuteSequence>
<!-- <CustomAction Id='LaunchProduct' FileKey='ApplicationExe' ExeCommand='' Return="asyncNoWait" /> -->
</Product>
</Wix>

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// La información general sobre un ensamblado se controla mediante el siguiente
// conjunto de atributos. Cambie estos atributos para modificar la información
// asociada con un ensamblado.
[assembly: AssemblyTitle("SparkleShareInviteOpen")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SparkleShareInviteOpen")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Si establece ComVisible como false, los tipos de este ensamblado no estarán visibles
// para los componentes COM. Si necesita obtener acceso a un tipo de este ensamblado desde
// COM, establezca el atributo ComVisible como true en este tipo.
[assembly: ComVisible(false)]
// El siguiente GUID sirve como identificador de typelib si este proyecto se expone a COM
[assembly: Guid("5d15209c-88a2-4d7f-9934-af24b8c90c55")]
// La información de versión de un ensamblado consta de los cuatro valores siguientes:
//
// Versión principal
// Versión secundaria
// Número de versión de compilación
// Revisión
//
// Puede especificar todos los valores o establecer como predeterminados los números de versión de compilación y de revisión
// mediante el asterisco ('*'), como se muestra a continuación:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1DB5492D-B897-4A5E-8DD7-175EC65F52F2}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SparkleShareInviteOpen</RootNamespace>
<AssemblyName>SparkleShareInviteOpen</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ApplicationIcon>..\..\..\data\icons\sparkleshare.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\..\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\sparkleshare-invite-open.cs">
<Link>sparkleshare-invite-open.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -0,0 +1,386 @@
// SparkleShare, a collaboration and sharing tool.
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.IO;
using SparkleLib;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.InteropServices;
namespace SparkleShare {
// The statusicon that stays in the
// user's notification area
public class SparkleStatusIcon : IDisposable {
public SparkleStatusIconController Controller = new SparkleStatusIconController();
private Timer Animation;
private Bitmap [] AnimationFrames;
private int FrameNumber;
private string StateText;
private ToolStripItem status_menu_item;
private NotifyIcon status_icon;
// Short alias for the translations
public static string _ (string s)
{
return Program._ (s);
}
public SparkleStatusIcon ()
{
AnimationFrames = CreateAnimationFrames ();
Animation = CreateAnimation ();
this.status_icon = new NotifyIcon ();
status_icon.Text = "SparkleShare";
status_icon.Icon = Icons.sparkleshare;
status_icon.Visible = true;
CreateMenu ();
SetNormalState ();
Program.Controller.FolderListChanged += delegate {
status_icon.ContextMenuStrip.SafeInvoke ((Action)delegate {
SetNormalState ();
CreateMenu ();
});
};
Program.Controller.OnIdle += delegate {
status_icon.ContextMenuStrip.SafeInvoke ((Action)delegate {
SetNormalState ();
UpdateMenu ();
});
};
Program.Controller.OnSyncing += delegate {
status_icon.ContextMenuStrip.SafeInvoke ((Action)delegate {
SetAnimationState ();
UpdateMenu ();
});
};
Program.Controller.OnError += delegate {
status_icon.ContextMenuStrip.SafeInvoke ((Action)delegate {
SetNormalState (true);
UpdateMenu ();
});
};
}
// Slices up the graphic that contains the
// animation frames.
private Bitmap [] CreateAnimationFrames ()
{
Bitmap [] animation_frames = new Bitmap [5];
animation_frames [0] = Icons.process_syncing_sparkleshare_i_24;
animation_frames [1] = Icons.process_syncing_sparkleshare_ii_24;
animation_frames [2] = Icons.process_syncing_sparkleshare_iii_24;
animation_frames [3] = Icons.process_syncing_sparkleshare_iiii_24;
animation_frames [4] = Icons.process_syncing_sparkleshare_iiiii_24;
return animation_frames;
}
[DllImport("user32.dll", EntryPoint = "DestroyIcon")]
static extern bool DestroyIcon(IntPtr hIcon);
private Icon GetIconFromBitmap (Bitmap bitmap)
{
IntPtr unmanagedIcon = bitmap.GetHicon();
Icon icon = (Icon)Icon.FromHandle(unmanagedIcon).Clone();
DestroyIcon(unmanagedIcon);
return icon;
}
// Creates the Animation that handles the syncing animation
private Timer CreateAnimation ()
{
FrameNumber = 0;
Timer Animation = new Timer () {
Interval = 35
};
Animation.Tick += delegate {
if (FrameNumber < AnimationFrames.Length - 1)
FrameNumber++;
else
FrameNumber = 0;
status_icon.ContextMenuStrip.SafeInvoke ((Action)delegate {
this.status_icon.Icon = GetIconFromBitmap( AnimationFrames [FrameNumber]);
});
};
return Animation;
}
// Creates the menu that is popped up when the
// user clicks the status icon
public void CreateMenu ()
{
ContextMenuStrip Menu = new ContextMenuStrip ();
// The menu item showing the status and size of the SparkleShare folder
status_menu_item = new ToolStripLabel (StateText);
Menu.Items.Add (status_menu_item);
Menu.Items.Add (new ToolStripSeparator ());
ToolStripMenuItem folder_item = new ToolStripMenuItem ("SparkleShare") {
Image = Icons.folder_sparkleshare_16
};
folder_item.Click += delegate {
Program.Controller.OpenSparkleShareFolder ();
};
Menu.Items.Add (folder_item);
if (Program.Controller.Folders.Count > 0) {
// Creates a menu item for each repository with a link to their logs
foreach (string folder_name in Program.Controller.Folders) {
Bitmap folder_icon;
if (Program.Controller.UnsyncedFolders.Contains (folder_name)) {
folder_icon = Icons.dialog_error_16;
} else {
folder_icon = Icons.sparkleshare_windows_status;
}
ToolStripMenuItem subfolder_item = new ToolStripMenuItem (folder_name) {
Image = folder_icon
};
subfolder_item.Click += OpenFolderDelegate (folder_name);
Menu.Items.Add (subfolder_item);
}
} else {
ToolStripMenuItem no_folders_item = new ToolStripMenuItem (_ ("No Remote Folders Yet")) {
Enabled = false
};
Menu.Items.Add (no_folders_item);
}
Menu.Items.Add (new ToolStripSeparator ());
// Opens the wizard to add a new remote folder
ToolStripMenuItem sync_item = new ToolStripMenuItem (_ ("Add Hosted Project…"));
if (Program.Controller.FirstRun)
sync_item.Enabled = false;
sync_item.Click += delegate {
Controller.AddHostedProjectClicked();
};
Menu.Items.Add (sync_item);
Menu.Items.Add (new ToolStripSeparator ());
ToolStripMenuItem recent_events_item = new ToolStripMenuItem (_ ("Open Recent Events"));
if (Program.Controller.Folders.Count < 1)
recent_events_item.Enabled = false;
recent_events_item.Click += delegate {
if (SparkleUI.EventLog == null)
SparkleUI.EventLog = new SparkleEventLog ();
SparkleUI.EventLog.Show ();
SparkleUI.EventLog.BringToFront ();
};
Menu.Items.Add (recent_events_item);
ToolStripMenuItem notify_item;
if (Program.Controller.NotificationsEnabled)
notify_item = new ToolStripMenuItem (_ ("Turn Notifications Off"));
else
notify_item = new ToolStripMenuItem (_ ("Turn Notifications On"));
notify_item.Click += delegate {
Program.Controller.ToggleNotifications ();
CreateMenu ();
};
Menu.Items.Add (notify_item);
Menu.Items.Add (new ToolStripSeparator ());
// A menu item that takes the user to http://www.sparkleshare.org/
ToolStripMenuItem about_item = new ToolStripMenuItem (_ ("About SparkleShare"));
about_item.Click += delegate {
if (SparkleUI.About == null)
SparkleUI.About = new SparkleAbout ();
SparkleUI.About.Show ();
SparkleUI.About.BringToFront ();
};
Menu.Items.Add (about_item);
Menu.Items.Add (new ToolStripSeparator ());
// A menu item that quits the application
ToolStripMenuItem quit_item = new ToolStripMenuItem (_ ("Quit"));
quit_item.Click += delegate {
Program.Controller.Quit ();
};
Menu.Items.Add (quit_item);
status_icon.ContextMenuStrip = Menu;
}
public void ShowBalloon (string title, string subtext, string image_path)
{
status_icon.BalloonTipText = title;
status_icon.BalloonTipText = subtext;
// TODO: Use the image pointed to by image_path
status_icon.BalloonTipIcon = ToolTipIcon.None;
status_icon.ShowBalloonTip (2 * 1000);
}
// A method reference that makes sure that opening the
// event log for each repository works correctly
private EventHandler OpenFolderDelegate (string name)
{
return delegate {
Program.Controller.OpenSparkleShareFolder (name);
};
}
public void UpdateMenu ()
{
status_menu_item.Text=StateText;
}
// The state when there's nothing going on
private void SetNormalState ()
{
SetNormalState (false);
}
// The state when there's nothing going on
private void SetNormalState (bool error)
{
Animation.Stop ();
if (Program.Controller.Folders.Count == 0) {
StateText = _("Welcome to SparkleShare!");
status_icon.ContextMenuStrip.SafeInvoke ((Action)delegate {
this.status_icon.Icon = GetIconFromBitmap (AnimationFrames [0]);
});
} else {
if (error) {
StateText = _("Not everything is synced");
status_icon.ContextMenuStrip.SafeInvoke ((Action)delegate {
this.status_icon.Icon = GetIconFromBitmap (Icons.sparkleshare_syncing_error_24);
});
} else {
StateText = _("Up to date") + " (" + FolderSize + ")";
status_icon.ContextMenuStrip.SafeInvoke ((Action)delegate {
this.status_icon.Icon = GetIconFromBitmap (AnimationFrames [0]);
});
}
}
}
// The state when animating
private void SetAnimationState ()
{
StateText = _("Syncing…");
if (!Animation.Enabled)
Animation.Start ();
}
public string FolderSize
{
get
{
double size = 0;
foreach (SparkleRepoBase repo in Program.Controller.Repositories)
size += repo.Size + repo.HistorySize;
return Program.Controller.FormatSize(size);
}
}
#region IDisposable Members
public void Dispose ()
{
status_icon.Dispose ();
}
#endregion
}
public static class ControlExtention {
public static void SafeInvoke (this Control uiElement, Action updater, bool forceSynchronous)
{
if (uiElement == null) {
//throw new ArgumentNullException ("uiElement");
return;
}
if (uiElement.InvokeRequired) {
if (forceSynchronous) {
uiElement.Invoke ((Action)delegate { SafeInvoke (uiElement, updater, forceSynchronous); });
} else {
uiElement.BeginInvoke ((Action)delegate { SafeInvoke (uiElement, updater, forceSynchronous); });
}
} else {
if (uiElement.IsDisposed) {
throw new ObjectDisposedException ("Control is already disposed.");
}
updater ();
}
}
public static void SafeInvoke (this Control uiElement, Action updater)
{
uiElement.SafeInvoke (updater, false);
}
}
}

View file

@ -0,0 +1,55 @@
// SparkleShare, a collaboration and sharing tool.
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System.Collections.Generic;
using System.Windows.Forms;
using SparkleLib;
using System;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Text;
namespace SparkleShare {
public static class SparkleUIHelpers {
// Creates an MD5 hash of input
public static string GetMD5 (string s)
{
MD5 md5 = new MD5CryptoServiceProvider ();
Byte[] bytes = ASCIIEncoding.Default.GetBytes (s);
Byte[] encodedBytes = md5.ComputeHash (bytes);
return BitConverter.ToString (encodedBytes).ToLower ().Replace ("-", "");
}
public static string ToHex (this System.Drawing.Color color)
{
return String.Format ("#{0:X2}{1:X2}{2:X2}", color.R, color.G, color.B);
}
//http://stackoverflow.com/a/1499161/33499
public static IEnumerable<Control> All (this Control.ControlCollection controls)
{
foreach (Control control in controls) {
foreach (Control grandChild in control.Controls.All ())
yield return grandChild;
yield return control;
}
}
}
}

View file

@ -0,0 +1,146 @@

// <autogenerated>
// This code was generated by a tool. Any changes made manually will be lost
// the next time this code is regenerated.
// </autogenerated>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Threading;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Reflection;
namespace SparkleShare
{
public class Strings
{
private static Object resourceManLock = new Object();
private static System.Resources.ResourceManager resourceMan;
private static System.Globalization.CultureInfo resourceCulture;
public const string ResourceName = "Strings";
private static string resourcesDir = GetSetting("ResourcesDir", "po");
private static string fileFormat = GetSetting("ResourcesFileFormat", "{{culture}}.po");
private static string GetSetting(string setting, string defaultValue)
{
var section = (System.Collections.Specialized.NameValueCollection)System.Configuration.ConfigurationManager.GetSection("appSettings");
if (section == null) return defaultValue;
else return section[setting] ?? defaultValue;
}
/// <summary>
/// Resources directory used to retrieve files from.
/// </summary>
public static string ResourcesDirectory
{
get { return resourcesDir; }
set { resourcesDir = value; }
}
/// <summary>
/// Format of the file based on culture and resource name.
/// </summary>
public static string FileFormat
{
get { return fileFormat; }
set { fileFormat = value; }
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
public static System.Resources.ResourceManager ResourceManager
{
get
{
if (object.ReferenceEquals(resourceMan, null))
{
lock (resourceManLock)
{
if (object.ReferenceEquals(resourceMan, null))
{
var directory = resourcesDir;
var mgr = new global::Gettext.Cs.GettextResourceManager(ResourceName, directory, fileFormat);
resourceMan = mgr;
}
}
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
public static System.Globalization.CultureInfo Culture
{
get { return resourceCulture; }
set { resourceCulture = value; }
}
/// <summary>
/// Looks up a localized string; used to mark string for translation as well.
/// </summary>
public static string T(string t)
{
return T(null, t);
}
/// <summary>
/// Looks up a localized string; used to mark string for translation as well.
/// </summary>
public static string T(CultureInfo info, string t)
{
if (String.IsNullOrEmpty(t)) return t;
var translated = ResourceManager.GetString(t, info ?? resourceCulture);
return String.IsNullOrEmpty(translated) ? t : translated;
}
/// <summary>
/// Looks up a localized string and formats it with the parameters provided; used to mark string for translation as well.
/// </summary>
public static string T(string t, params object[] parameters)
{
return T(null, t, parameters);
}
/// <summary>
/// Looks up a localized string and formats it with the parameters provided; used to mark string for translation as well.
/// </summary>
public static string T(CultureInfo info, string t, params object[] parameters)
{
if (String.IsNullOrEmpty(t)) return t;
return String.Format(T(info, t), parameters);
}
/// <summary>
/// Marks a string for future translation, does not translate it now.
/// </summary>
public static string M(string t)
{
return t;
}
/// <summary>
/// Returns the resource set available for the specified culture.
/// </summary>
public static System.Resources.ResourceSet GetResourceSet(CultureInfo culture)
{
return ResourceManager.GetResourceSet(culture, true, true);
}
}
}

View file

@ -0,0 +1,10 @@
<#@ assembly name="System.Configuration" #>
<#
this.ClassName = "Strings";
this.ResourceName = "Strings";
this.NamespaceName = "SparkleShare";
this.DefaultResourceDir = "po";
this.DefaultFileFormat = "{{culture}}.po";
#>
<#@ include file="..\..\tools\gettext-cs-utils\Gettext.CsUtils\Core\Gettext.Cs\Templates\Strings.tt" #>

View file

@ -0,0 +1,35 @@
@echo off
call %~dp0\..\..\data\plugins\build.cmd
set WinDirNet=%WinDir%\Microsoft.NET\Framework
set msbuild="%WinDirNet%\v3.5\msbuild.exe"
if not exist %msbuild% set msbuild="%WinDirNet%\v4.0.30319\msbuild.exe"
set wixBinDir=%WIX%\bin
cd lib
copy * ..\..\..\bin
cd ..
cp ..\..\data\icons\sparkleshare.ico ..\..\bin
%msbuild% /t:Rebuild /p:Configuration=Release /p:Platform="AnyCPU" %~dp0\tools\gettext-cs-utils\Gettext.CsUtils\Core\Gettext.Cs\Gettext.Cs.csproj
%msbuild% /t:Rebuild /p:Configuration=Release /p:Platform="Any CPU" %~dp0\SparkleShare.sln
if "%1"=="installer" (
if exist "%wixBinDir%" (
if exist "%~dp0\SparkleShare.msi" del "%~dp0\SparkleShare.msi"
"%wixBinDir%\heat.exe" dir "%~dp0\..\..\bin\msysgit" -cg msysGitComponentGroup -gg -scom -sreg -sfrag -srd -dr MSYSGIT_DIR -var wix.msysgitpath -o msysgit.wxs
"%wixBinDir%\heat.exe" dir "%~dp0\..\..\bin\po" -cg poComponentGroup -gg -scom -sreg -sfrag -srd -dr PO_DIR -var wix.podir -o po.wxs
"%wixBinDir%\heat.exe" dir "%~dp0\..\..\bin\plugins" -cg pluginsComponentGroup -gg -scom -sreg -sfrag -srd -dr PLUGINS_DIR -var wix.pluginsdir -o plugins.wxs
"%wixBinDir%\candle" "%~dp0\SparkleShare.wxs" -ext WixUIExtension -ext WixUtilExtension
"%wixBinDir%\candle" "%~dp0\msysgit.wxs" -ext WixUIExtension -ext WixUtilExtension
"%wixBinDir%\candle" "%~dp0\po.wxs" -ext WixUIExtension -ext WixUtilExtension
"%wixBinDir%\candle" "%~dp0\plugins.wxs" -ext WixUIExtension -ext WixUtilExtension
"%wixBinDir%\light" -ext WixUIExtension -ext WixUtilExtension Sparkleshare.wixobj msysgit.wixobj po.wixobj plugins.wixobj -droot="%~dp0\..\.." -dmsysgitpath="%~dp0\..\..\bin\msysgit" -dpodir="%~dp0\..\..\bin\po" -dpluginsdir="%~dp0\..\..\bin\plugins" -o SparkleShare.msi
if exist "%~dp0\SparkleShare.msi" echo SparkleShare.msi created.
) else (
echo Not building installer ^(could not find wix, Windows Installer XML toolset^)
echo wix is available at http://wix.sourceforge.net/
)
) else echo Not building installer, as it was not requested. ^(Issue "build.cmd installer" to build installer ^)

View file

@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SparkleShare.controls {
public class ExampleTextBox : TextBox {
private bool ExampleTextActive = true;
private bool OnTextChangedActive = true;
private bool _focused = false;
private string _ExampleText = "";
public string ExampleText
{
get { return _ExampleText; }
set
{
_ExampleText = value;
if (ExampleTextActive)
ActivateExampleText ();
}
}
public override string Text
{
get
{
if (ExampleTextActive)
return "";
return base.Text;
}
set
{
if (String.IsNullOrEmpty (value)) {
ActivateExampleText ();
} else {
ExampleTextActive = false;
ForeColor = System.Drawing.SystemColors.WindowText;
base.Text = value;
}
}
}
private void ActivateExampleText ()
{
OnTextChangedActive = false;
base.Text = ExampleText;
OnTextChangedActive = true;
ExampleTextActive = true;
ForeColor = System.Drawing.SystemColors.InactiveCaptionText;
}
protected override void OnTextChanged (EventArgs e)
{
if (!OnTextChangedActive)
return;
bool Empty = String.IsNullOrEmpty (base.Text);
if (Empty) {
ActivateExampleText ();
SelectAll ();
} else if (ExampleTextActive) {
ExampleTextActive = false;
ForeColor = System.Drawing.SystemColors.WindowText;
}
base.OnTextChanged (e);
}
protected override void OnEnter (EventArgs e)
{
base.OnEnter (e);
if (ExampleTextActive && MouseButtons == MouseButtons.None) {
SelectAll ();
_focused = true;
}
}
protected override void OnLeave (EventArgs e)
{
base.OnLeave (e);
_focused = false;
}
protected override void OnMouseUp (MouseEventArgs mevent)
{
base.OnMouseUp (mevent);
if (!_focused) {
if (ExampleTextActive && SelectionLength == 0)
SelectAll ();
_focused = true;
}
}
}
}

View file

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SparkleShare.controls {
public class TablessControl : TabControl {
protected override void WndProc (ref Message m)
{
if (m.Msg == 0x1328 && !DesignMode)
m.Result = (IntPtr)1;
else
base.WndProc (ref m);
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View file

@ -0,0 +1,2 @@
.gitattributes eol=lf
.gitmodules eol=lf

View file

@ -0,0 +1,11 @@
*~
*.bak
*.suo
*.user
*.sln.cache
bin/
obj/
_ReSharper.*/
_UpgradeReport_Files/
Backup/
UpgradeLog.XML

View file

@ -0,0 +1,9 @@
2009-08-12 Michael Hutchinson <mhutchinson@novell.com>
* Makefile.am:
* TextTransform:
* Mono.TextTemplating:
* Mono.TextTemplating.Tests:
* MonoDevelop.TextTemplating: Include the ASP.NET MVC and
TextTemplating addins in the main solution and build.

View file

@ -0,0 +1,4 @@
SUBDIRS = \
Mono.TextTemplating \
TextTransform \
MonoDevelop.TextTemplating

View file

@ -0,0 +1,65 @@
2009-12-11 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating.Tests.csproj: Don't local-copy nunit.
2009-11-27 Olivier Dagenais <olivier.dagenais@gmail.com>
* GenerationTests.cs: Make tests independent of the runtime
they are running under by stripping the "autogenerated"
comment (i.e. the first 9 lines).
2009-10-29 Lluis Sanchez Gual <lluis@novell.com>
* Mono.TextTemplating.Tests.csproj: Flush.
2009-08-13 Lluis Sanchez Gual <lluis@novell.com>
* DummyHost.cs: Fix windows build.
2009-08-13 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating.Tests.csproj: Use assembly refs for
nunit.
2009-08-12 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating.Tests.csproj: Include the ASP.NET MVC
and TextTemplating addins in the main solution and build.
2009-04-13 Michael Hutchinson <mhutchinson@novell.com>
* GenerationTests.cs: Add tests for Windows/Mac newlines.
2009-04-03 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating.Tests.csproj: Updated.
* GenerationTests.cs: Add test for C# output.
* ParsingTests.cs: Track dummy host name change.
* DummyHost.cs: Add more functionality to dummy host.
2009-03-13 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating.Tests.csproj: Move output dir from
../bin to ../build.
2009-03-13 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating.Tests.csproj: Fix output directory.
2009-03-12 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating.Tests.csproj: Updated.
* ParsingTests.cs: Add parser test.
* DummyHost.cs: Dummy templating host.
2009-03-12 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating.Tests.csproj: Add tests.
* ParsingTests.cs: Tokeniser state/value/location test.

View file

@ -0,0 +1,113 @@
//
// IncludeFileProviderHost.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.CodeDom.Compiler;
using Microsoft.VisualStudio.TextTemplating;
namespace Mono.TextTemplating.Tests
{
public class DummyHost : ITextTemplatingEngineHost
{
public readonly Dictionary<string, string> Locations = new Dictionary<string, string> ();
public readonly Dictionary<string, string> Contents = new Dictionary<string, string> ();
public readonly Dictionary<string, object> HostOptions = new Dictionary<string, object> ();
List<string> standardAssemblyReferences = new List<string> ();
List<string> standardImports = new List<string> ();
public readonly CompilerErrorCollection Errors = new CompilerErrorCollection ();
public readonly Dictionary<string, Type> DirectiveProcessors = new Dictionary<string, Type> ();
public virtual object GetHostOption (string optionName)
{
object o;
HostOptions.TryGetValue (optionName, out o);
return o;
}
public virtual bool LoadIncludeText (string requestFileName, out string content, out string location)
{
content = null;
return Locations.TryGetValue (requestFileName, out location)
&& Contents.TryGetValue (requestFileName, out content);
}
public virtual void LogErrors (CompilerErrorCollection errors)
{
Errors.AddRange (errors);
}
public virtual AppDomain ProvideTemplatingAppDomain (string content)
{
return null;
}
public virtual string ResolveAssemblyReference (string assemblyReference)
{
throw new System.NotImplementedException();
}
public virtual Type ResolveDirectiveProcessor (string processorName)
{
Type t;
DirectiveProcessors.TryGetValue (processorName, out t);
return t;
}
public virtual string ResolveParameterValue (string directiveId, string processorName, string parameterName)
{
throw new System.NotImplementedException();
}
public virtual string ResolvePath (string path)
{
throw new System.NotImplementedException();
}
public virtual void SetFileExtension (string extension)
{
throw new System.NotImplementedException();
}
public virtual void SetOutputEncoding (System.Text.Encoding encoding, bool fromOutputDirective)
{
throw new System.NotImplementedException();
}
public virtual IList<string> StandardAssemblyReferences {
get { return standardAssemblyReferences; }
}
public virtual IList<string> StandardImports {
get { return standardImports; }
}
public virtual string TemplateFile {
get; set;
}
}
}

View file

@ -0,0 +1,171 @@
//
// GenerationTests.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.IO;
using NUnit.Framework;
using Microsoft.VisualStudio.TextTemplating;
namespace Mono.TextTemplating.Tests
{
[TestFixture]
public class GenerationTests
{
[Test]
public void Generate ()
{
string Input = ParsingTests.ParseSample1;
string Output = OutputSample1;
Generate (Input, Output, "\n");
}
[Test]
public void GenerateMacNewlines ()
{
string MacInput = ParsingTests.ParseSample1.Replace ("\n", "\r");
string MacOutput = OutputSample1.Replace ("\\n", "\\r").Replace ("\n", "\r");;
Generate (MacInput, MacOutput, "\r");
}
[Test]
public void GenerateWindowsNewlines ()
{
string WinInput = ParsingTests.ParseSample1.Replace ("\n", "\r\n");
string WinOutput = OutputSample1.Replace ("\\n", "\\r\\n").Replace ("\n", "\r\n");
Generate (WinInput, WinOutput, "\r\n");
}
//NOTE: we set the newline property on the code generator so that the whole files has matching newlines,
// in order to match the newlines in the verbatim code blocks
void Generate (string input, string expectedOutput, string newline)
{
DummyHost host = new DummyHost ();
string className = "GeneratedTextTransformation4f504ca0";
string code = GenerateCode (host, input, className, newline);
Assert.AreEqual (0, host.Errors.Count);
Assert.AreEqual (expectedOutput, TemplatingEngineHelper.StripHeader (code, newline));
}
#region Helpers
string GenerateCode (ITextTemplatingEngineHost host, string content, string name, string generatorNewline)
{
ParsedTemplate pt = ParsedTemplate.FromText (content, host);
if (pt.Errors.HasErrors) {
host.LogErrors (pt.Errors);
return null;
}
TemplateSettings settings = TemplatingEngine.GetSettings (host, pt);
if (name != null)
settings.Name = name;
if (pt.Errors.HasErrors) {
host.LogErrors (pt.Errors);
return null;
}
var ccu = TemplatingEngine.GenerateCompileUnit (host, content, pt, settings);
if (pt.Errors.HasErrors) {
host.LogErrors (pt.Errors);
return null;
}
var opts = new System.CodeDom.Compiler.CodeGeneratorOptions ();
using (var writer = new System.IO.StringWriter ()) {
writer.NewLine = generatorNewline;
settings.Provider.GenerateCodeFromCompileUnit (ccu, writer, opts);
return writer.ToString ();
}
}
#endregion
#region Expected output strings
public static string OutputSample1 =
@"
namespace Microsoft.VisualStudio.TextTemplating {
public partial class GeneratedTextTransformation4f504ca0 : global::Microsoft.VisualStudio.TextTemplating.TextTransformation {
#line 9 """"
baz \#>
#line default
#line hidden
public override string TransformText() {
this.GenerationEnvironment = null;
#line 2 """"
this.Write(""Line One\nLine Two\n"");
#line default
#line hidden
#line 4 """"
foo
#line default
#line hidden
#line 7 """"
this.Write(""Line Three "");
#line default
#line hidden
#line 7 """"
this.Write(global::Microsoft.VisualStudio.TextTemplating.ToStringHelper.ToStringWithCulture( bar ));
#line default
#line hidden
#line 7 """"
this.Write(""\nLine Four\n"");
#line default
#line hidden
return this.GenerationEnvironment.ToString();
}
protected override void Initialize() {
base.Initialize();
}
}
}
";
#endregion
}
}

View file

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CB590106-8331-4CBE-8131-B154E7BF79E1}</ProjectGuid>
<OutputType>Library</OutputType>
<AssemblyName>Mono.TextTemplating.Tests</AssemblyName>
<RootNamespace>Mono.TextTemplating.Tests</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="nunit.core">
<HintPath>..\NUnit\lib\nunit.core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\NUnit\lib\nunit.framework.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ParsingTests.cs" />
<Compile Include="DummyHost.cs" />
<Compile Include="GenerationTests.cs" />
<Compile Include="TemplatingEngineHelper.cs" />
<Compile Include="TemplateEnginePreprocessTemplateTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Mono.TextTemplating\Mono.TextTemplating.csproj">
<Project>{A2364D6A-00EF-417C-80A6-815726C70032}</Project>
<Name>Mono.TextTemplating</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,191 @@
//
// Test.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using NUnit.Framework;
namespace Mono.TextTemplating.Tests
{
[TestFixture]
public class ParsingTests
{
public static string ParseSample1 =
@"<#@ template language=""C#v3.5"" #>
Line One
Line Two
<#
foo
#>
Line Three <#= bar #>
Line Four
<#+
baz \#>
#>
";
[Test]
public void TokenTest ()
{
string tf = "test.input";
Tokeniser tk = new Tokeniser (tf, ParseSample1);
//line 1
Assert.IsTrue (tk.Advance ());
Assert.AreEqual (new Location (tf, 1, 1), tk.Location);
Assert.AreEqual (State.Content, tk.State);
Assert.AreEqual ("", tk.Value);
Assert.IsTrue (tk.Advance ());
Assert.AreEqual (State.Directive, tk.State);
Assert.IsTrue (tk.Advance ());
Assert.AreEqual (new Location (tf, 1, 5), tk.Location);
Assert.AreEqual (State.DirectiveName, tk.State);
Assert.AreEqual ("template", tk.Value);
Assert.IsTrue (tk.Advance ());
Assert.AreEqual (State.Directive, tk.State);
Assert.IsTrue (tk.Advance ());
Assert.AreEqual (new Location (tf, 1, 14), tk.Location);
Assert.AreEqual (State.DirectiveName, tk.State);
Assert.AreEqual ("language", tk.Value);
Assert.IsTrue (tk.Advance ());
Assert.AreEqual (State.Directive, tk.State);
Assert.IsTrue (tk.Advance ());
Assert.AreEqual (State.DirectiveValue, tk.State);
Assert.AreEqual (new Location (tf, 1, 23), tk.Location);
Assert.AreEqual ("C#v3.5", tk.Value);
Assert.IsTrue (tk.Advance ());
Assert.AreEqual (State.Directive, tk.State);
//line 2, 3
Assert.IsTrue (tk.Advance ());
Assert.AreEqual (new Location (tf, 2, 1), tk.Location);
Assert.AreEqual (State.Content, tk.State);
Assert.AreEqual ("Line One\nLine Two\n", tk.Value);
//line 4, 5, 6
Assert.IsTrue (tk.Advance ());
Assert.AreEqual (new Location (tf, 4, 1), tk.TagStartLocation);
Assert.AreEqual (new Location (tf, 4, 3), tk.Location);
Assert.AreEqual (new Location (tf, 6, 3), tk.TagEndLocation);
Assert.AreEqual (State.Block, tk.State);
Assert.AreEqual ("\nfoo\n", tk.Value);
//line 7
Assert.IsTrue (tk.Advance ());
Assert.AreEqual (new Location (tf, 7, 1), tk.Location);
Assert.AreEqual (State.Content, tk.State);
Assert.AreEqual ("Line Three ", tk.Value);
Assert.IsTrue (tk.Advance ());
Assert.AreEqual (new Location (tf, 7, 12), tk.TagStartLocation);
Assert.AreEqual (new Location (tf, 7, 15), tk.Location);
Assert.AreEqual (new Location (tf, 7, 22), tk.TagEndLocation);
Assert.AreEqual (State.Expression, tk.State);
Assert.AreEqual (" bar ", tk.Value);
//line 8
Assert.IsTrue (tk.Advance ());
Assert.AreEqual (new Location (tf, 7, 22), tk.Location);
Assert.AreEqual (State.Content, tk.State);
Assert.AreEqual ("\nLine Four\n", tk.Value);
//line 9, 10, 11
Assert.IsTrue (tk.Advance ());
Assert.AreEqual (new Location (tf, 9, 1), tk.TagStartLocation);
Assert.AreEqual (new Location (tf, 9, 4), tk.Location);
Assert.AreEqual (new Location (tf, 11, 3), tk.TagEndLocation);
Assert.AreEqual (State.Helper, tk.State);
Assert.AreEqual (" \nbaz \\#>\n", tk.Value);
//line 12
Assert.IsTrue (tk.Advance ());
Assert.AreEqual (new Location (tf, 12, 1), tk.Location);
Assert.AreEqual (State.Content, tk.State);
Assert.AreEqual ("", tk.Value);
//EOF
Assert.IsFalse (tk.Advance ());
Assert.AreEqual (new Location (tf, 12, 1), tk.Location);
Assert.AreEqual (State.EOF, tk.State);
}
[Test]
public void ParseTest ()
{
string tf = "test.input";
ParsedTemplate pt = new ParsedTemplate ("test.input");
Tokeniser tk = new Tokeniser (tf, ParseSample1);
DummyHost host = new DummyHost ();
pt.Parse (host, tk);
Assert.AreEqual (0, pt.Errors.Count);
var content = new List<TemplateSegment> (pt.Content);
var dirs = new List<Directive> (pt.Directives);
Assert.AreEqual (1, dirs.Count);
Assert.AreEqual (6, content.Count);
Assert.AreEqual ("template", dirs[0].Name);
Assert.AreEqual (1, dirs[0].Attributes.Count);
Assert.AreEqual ("C#v3.5", dirs[0].Attributes["language"]);
Assert.AreEqual (new Location (tf, 1, 1), dirs[0].TagStartLocation);
Assert.AreEqual (new Location (tf, 1, 34), dirs[0].EndLocation);
Assert.AreEqual ("Line One\nLine Two\n", content[0].Text);
Assert.AreEqual ("\nfoo\n", content[1].Text);
Assert.AreEqual ("Line Three ", content[2].Text);
Assert.AreEqual (" bar ", content[3].Text);
Assert.AreEqual ("\nLine Four\n", content[4].Text);
Assert.AreEqual (" \nbaz \\#>\n", content[5].Text);
Assert.AreEqual (SegmentType.Content, content[0].Type);
Assert.AreEqual (SegmentType.Block, content[1].Type);
Assert.AreEqual (SegmentType.Content, content[2].Type);
Assert.AreEqual (SegmentType.Expression, content[3].Type);
Assert.AreEqual (SegmentType.Content, content[4].Type);
Assert.AreEqual (SegmentType.Helper, content[5].Type);
Assert.AreEqual (new Location (tf, 4, 1), content[1].TagStartLocation);
Assert.AreEqual (new Location (tf, 7, 12), content[3].TagStartLocation);
Assert.AreEqual (new Location (tf, 9, 1), content[5].TagStartLocation);
Assert.AreEqual (new Location (tf, 2, 1), content[0].StartLocation);
Assert.AreEqual (new Location (tf, 4, 3), content[1].StartLocation);
Assert.AreEqual (new Location (tf, 7, 1), content[2].StartLocation);
Assert.AreEqual (new Location (tf, 7, 15), content[3].StartLocation);
Assert.AreEqual (new Location (tf, 7, 22), content[4].StartLocation);
Assert.AreEqual (new Location (tf, 9, 4), content[5].StartLocation);
Assert.AreEqual (new Location (tf, 6, 3), content[1].EndLocation);
Assert.AreEqual (new Location (tf, 7, 22), content[3].EndLocation);
Assert.AreEqual (new Location (tf, 11, 3), content[5].EndLocation);
}
}
}

View file

@ -0,0 +1,246 @@
//
// TemplateEnginePreprocessTemplateTests.cs
//
// Author:
// Matt Ward
//
// Copyright (c) 2010 Matt Ward
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.IO;
using NUnit.Framework;
using Microsoft.VisualStudio.TextTemplating;
namespace Mono.TextTemplating.Tests
{
[TestFixture]
public class TemplateEnginePreprocessTemplateTests
{
[Test]
public void Preprocess ()
{
string input =
"<#@ template language=\"C#\" #>\r\n" +
"Test\r\n";
string expectedOutput = OutputSample1;
string output = Preprocess (input);
Assert.AreEqual (expectedOutput, output);
}
#region Helpers
string Preprocess (string input)
{
DummyHost host = new DummyHost ();
string className = "PreprocessedTemplate";
string classNamespace = "Templating";
string language = null;
string[] references = null;
TemplatingEngine engine = new TemplatingEngine ();
string output = engine.PreprocessTemplate (input, host, className, classNamespace, out language, out references);
output = output.Replace ("\r\n", "\n");
return TemplatingEngineHelper.StripHeader (output, "\n");
}
#endregion
#region Expected output strings
public static string OutputSample1 =
@"
namespace Templating {
public partial class PreprocessedTemplate : PreprocessedTemplateBase {
public virtual string TransformText() {
this.GenerationEnvironment = null;
#line 2 """"
this.Write(""Test\r\n"");
#line default
#line hidden
return this.GenerationEnvironment.ToString();
}
protected virtual void Initialize() {
}
}
public class PreprocessedTemplateBase {
private global::System.Text.StringBuilder builder;
private global::System.Collections.Generic.IDictionary<string, object> session;
private global::System.CodeDom.Compiler.CompilerErrorCollection errors;
private string currentIndent = string.Empty;
private global::System.Collections.Generic.Stack<int> indents;
private ToStringInstanceHelper _toStringHelper = new ToStringInstanceHelper();
public virtual global::System.Collections.Generic.IDictionary<string, object> Session {
get {
return this.session;
}
set {
this.session = value;
}
}
public global::System.Text.StringBuilder GenerationEnvironment {
get {
if ((this.builder == null)) {
this.builder = new global::System.Text.StringBuilder();
}
return this.builder;
}
set {
this.builder = value;
}
}
protected global::System.CodeDom.Compiler.CompilerErrorCollection Errors {
get {
if ((this.errors == null)) {
this.errors = new global::System.CodeDom.Compiler.CompilerErrorCollection();
}
return this.errors;
}
}
public string CurrentIndent {
get {
return this.currentIndent;
}
}
private global::System.Collections.Generic.Stack<int> Indents {
get {
if ((this.indents == null)) {
this.indents = new global::System.Collections.Generic.Stack<int>();
}
return this.indents;
}
}
public ToStringInstanceHelper ToStringHelper {
get {
return this._toStringHelper;
}
}
public void Error(string message) {
this.Errors.Add(new global::System.CodeDom.Compiler.CompilerError(null, -1, -1, null, message));
}
public void Warning(string message) {
global::System.CodeDom.Compiler.CompilerError val = new global::System.CodeDom.Compiler.CompilerError(null, -1, -1, null, message);
val.IsWarning = true;
this.Errors.Add(val);
}
public string PopIndent() {
if ((this.Indents.Count == 0)) {
return string.Empty;
}
int lastPos = (this.currentIndent.Length - this.Indents.Pop());
string last = this.currentIndent.Substring(lastPos);
this.currentIndent = this.currentIndent.Substring(0, lastPos);
return last;
}
public void PushIndent(string indent) {
this.Indents.Push(indent.Length);
this.currentIndent = (this.currentIndent + indent);
}
public void ClearIndent() {
this.currentIndent = string.Empty;
this.Indents.Clear();
}
public void Write(string textToAppend) {
this.GenerationEnvironment.Append(textToAppend);
}
public void Write(string format, params object[] args) {
this.GenerationEnvironment.AppendFormat(format, args);
}
public void WriteLine(string textToAppend) {
this.GenerationEnvironment.Append(this.currentIndent);
this.GenerationEnvironment.AppendLine(textToAppend);
}
public void WriteLine(string format, params object[] args) {
this.GenerationEnvironment.Append(this.currentIndent);
this.GenerationEnvironment.AppendFormat(format, args);
this.GenerationEnvironment.AppendLine();
}
public class ToStringInstanceHelper {
private global::System.IFormatProvider formatProvider = global::System.Globalization.CultureInfo.InvariantCulture;
public global::System.IFormatProvider FormatProvider {
get {
return this.formatProvider;
}
set {
if ((this.formatProvider == null)) {
throw new global::System.ArgumentNullException(""formatProvider"");
}
this.formatProvider = value;
}
}
public string ToStringWithCulture(object objectToConvert) {
if ((objectToConvert == null)) {
throw new global::System.ArgumentNullException(""objectToConvert"");
}
global::System.Type type = objectToConvert.GetType();
global::System.Type iConvertibleType = typeof(global::System.IConvertible);
if (iConvertibleType.IsAssignableFrom(type)) {
return ((global::System.IConvertible)(objectToConvert)).ToString(this.formatProvider);
}
global::System.Reflection.MethodInfo methInfo = type.GetMethod(""ToString"", new global::System.Type[] {
iConvertibleType});
if ((methInfo != null)) {
return ((string)(methInfo.Invoke(objectToConvert, new object[] {
this.formatProvider})));
}
return objectToConvert.ToString();
}
}
}
}
";
#endregion
}
}

View file

@ -0,0 +1,51 @@
//
// Test.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.IO;
namespace Mono.TextTemplating.Tests
{
public static class TemplatingEngineHelper
{
public static string StripHeader (string input, string newLine)
{
using (var writer = new StringWriter ()) {
using (var reader = new StringReader (input)) {
for (int i = 0; i < 9; i++) {
reader.ReadLine ();
}
string line;
while ((line = reader.ReadLine ()) != null) {
writer.Write (line);
writer.Write (newLine);
}
}
return writer.ToString ();
}
}
}
}

View file

@ -0,0 +1,37 @@
//
// AssemblyInfo.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System.Reflection;
using System.Runtime.CompilerServices;
using System;
[assembly: AssemblyTitle("Mono.TextTemplating")]
[assembly: AssemblyDescription("An implementation of Visual Studio's T4 text templating")]
[assembly: AssemblyCompany("The Mono Project")]
[assembly: AssemblyProduct("MonoDevelop")]
[assembly: AssemblyCopyright("MIT/X11")]
[assembly: CLSCompliant (true)]
//[assembly: AssemblyVersion("1.0.0.0")]

View file

@ -0,0 +1,212 @@
2010-03-15 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating/TemplateGenerator.cs: Expose OutputFile
for custom tool to access.
2010-03-01 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating/CrossAppDomainAssemblyResolver.cs: A
handler for AssemblyResolve events that looks them up in the
domain that created the resolver.
* Makefile.am:
* Mono.TextTemplating.csproj: Added file.
2009-11-27 Olivier Dagenais <olivier.dagenais@gmail.com>
* Mono.TextTemplating/ParsedTemplate.cs: Fixed a bug where the
location of an error was being ignored.
2009-11-27 Olivier Dagenais <olivier.dagenais@gmail.com>
* Mono.TextTemplating/TemplatingEngine.cs: Mark the generated
type as partial.
2009-11-25 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating/ParsedTemplate.cs: Don't check if
included file exists before trying to resolve it from the
host, because host may use include paths. Patch from Aaron
Bockover.
2009-08-17 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating/TemplatingEngine.cs: Fix NRE when
template fails to compile.
2009-08-12 Michael Hutchinson <mhutchinson@novell.com>
* Makefile.am:
* Mono.TextTemplating.csproj: Include the ASP.NET MVC and
TextTemplating addins in the main solution and build.
2009-08-11 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating.csproj:
* Mono.TextTemplating/ParsedTemplate.cs:
* Mono.TextTemplating/CompiledTemplate.cs:
* Mono.TextTemplating/TemplatingEngine.cs:
* Mono.TextTemplating/TemplateGenerator.cs:
* Mono.TextTemplating/IExtendedTextTemplatingEngineHost.cs:
Add support for caching compiled templates, and a couple of
bugfixes. Patch from Nathan Baulch
(nathan.baulch@gmail.com).
2009-06-25 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating/TemplatingEngine.cs: Handle expressions
and content in helpers, based on patch from Nathan Baulch.
Liberally add C# 3 sugar to neaten up CodeDOM usage.
2009-06-25 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating/TemplateGenerator.cs: Added overload for
Process template that uses input/output strings directly,
avoiding file read/write. Expose engine to subclasses.
* Mono.TextTemplating/Tokeniser.cs: Remove outdated TODO.
2009-04-13 Michael Hutchinson <mhutchinson@novell.com>
* Microsoft.VisualStudio.TextTemplating/ToStringHelper.cs: Use
IConvertible.ToString (formatProvider) when possible.
Thanks to Stuart Carnie for this patch.
2009-04-13 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating/Tokeniser.cs: Add support for Mac and
Windows newlines.
* Mono.TextTemplating/TemplatingEngine.cs: Keep temp files
when in debug mode, so that the generated code can be
debugged.
* Mono.TextTemplating/ParsedTemplate.cs: Fixes for csc
compilation.
Thanks to Stuart Carnie for this patch.
2009-04-03 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating.csproj:
* Mono.TextTemplating/TemplatingEngine.cs:
* Mono.TextTemplating/TemplateSettings.cs:
* Microsoft.VisualStudio.TextTemplating/Engine.cs: Move the
real engine into the Mono.TextTemplating namespace and
expose helper methods so that they can be tested.
2009-03-13 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating.csproj: Move output dir from ../bin to
../build.
2009-03-12 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating/Tokeniser.cs: Tweaked location of next
state after directive.
2009-03-12 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating/Tokeniser.cs: Location tweaks within
directives.
* Mono.TextTemplating/ParsedTemplate.cs: Make Location
equatable.
2009-03-10 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating/Tokeniser.cs:
* Mono.TextTemplating/ParsedTemplate.cs: Fix end location
capture after newline handling changes.
2009-03-10 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating/Tokeniser.cs:
* Microsoft.VisualStudio.TextTemplating/Engine.cs: Match T4's
newline handling.
2009-03-10 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating/ParsedTemplate.cs: Fix logic that
prevented adding directives.
2009-03-09 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating/Tokeniser.cs:
* Mono.TextTemplating/ParsedTemplate.cs: More accurate
location captures. Capture start of tags as well as start of
content.
2009-03-09 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating/TemplateGenerator.cs: Report exceptions
in errors.
* Mono.TextTemplating/Tokeniser.cs: Make API public.
* Mono.TextTemplating/ParsedTemplate.cs: Unify segment types.
Track end locations. Make API public. Allow parsing without
includes.
* Microsoft.VisualStudio.TextTemplating/Engine.cs: Track
location API.
2009-03-06 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating/TemplateGenerator.cs: Fix
SetFileExtension.
* Microsoft.VisualStudio.TextTemplating/Engine.cs: Capture
hostspecific attribute from template directive.
2009-03-05 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating/TemplateGenerator.cs: Fix output
extension changing.
* Mono.TextTemplating/Tokeniser.cs: Fix helper regions.
2009-03-05 Michael Hutchinson <mhutchinson@novell.com>
* Mono.TextTemplating.csproj: Updated.
* Mono.TextTemplating/TemplateGenerator.cs: Simple template
host implementation. Doesn't handle everything yet.
* Mono.TextTemplating/Tokeniser.cs: Fix a number of offset
issues that broke most captures. Only allow EOF in content
regions, and in this case capture the last content. Track
current column, for error reporting.
* Mono.TextTemplating/ParsedTemplate.cs: Overhaul location
tracking for error reporting. Don't record empty segments.
* Microsoft.VisualStudio.TextTemplating/Engine.cs: Use run
method instead of runner, since the whole thing's done in
the appdomain now. Catch errors from the runner. Use host's
default assemblies and imports. Track ParsedTemplate error
reporting changes. Filter out content regions with only a
single newline.
* Microsoft.VisualStudio.TextTemplating/ToStringHelper.cs:
Don't cache delegates; this won't work for instances. Maybe
IL generation is called for.
2009-03-04 Michael Hutchinson <mhutchinson@novell.com>
* AssemblyInfo.cs:
* Mono.TextTemplating:
* Mono.TextTemplating.csproj:
* Mono.TextTemplating/Tokeniser.cs:
* Microsoft.VisualStudio.TextTemplating:
* Mono.TextTemplating/ParsedTemplate.cs:
* Microsoft.VisualStudio.TextTemplating/Engine.cs:
* Microsoft.VisualStudio.TextTemplating/ToStringHelper.cs:
* Microsoft.VisualStudio.TextTemplating/DirectiveProcessor.cs:
* Microsoft.VisualStudio.TextTemplating/TextTransformation.cs:
* Microsoft.VisualStudio.TextTemplating/ITextTemplatingEngineHost.cs:
* Microsoft.VisualStudio.TextTemplating/DirectiveProcessorException.cs:
* Microsoft.VisualStudio.TextTemplating/RequiresProvidesDirectiveProcessor.cs:
Move T4 implementation to its own assembly. Tweak some
appdomain stuff.

View file

@ -0,0 +1,55 @@
ADDIN_BUILD = $(top_builddir)/build/AddIns/MonoDevelop.TextTemplating
ASSEMBLY = $(ADDIN_BUILD)/Mono.TextTemplating.dll
DEPS =
REFS = \
-r:System \
-r:System.Core
FILES = \
AssemblyInfo.cs \
Microsoft.VisualStudio.TextTemplating/AssemblyCacheMonitor.cs \
Microsoft.VisualStudio.TextTemplating/DirectiveProcessor.cs \
Microsoft.VisualStudio.TextTemplating/DirectiveProcessorException.cs \
Microsoft.VisualStudio.TextTemplating/EncodingHelper.cs \
Microsoft.VisualStudio.TextTemplating/Engine.cs \
Microsoft.VisualStudio.TextTemplating/Interfaces.cs \
Microsoft.VisualStudio.TextTemplating/ParameterDirectiveProcessor.cs \
Microsoft.VisualStudio.TextTemplating/RequiresProvidesDirectiveProcessor.cs \
Microsoft.VisualStudio.TextTemplating/TextTemplatingSession.cs \
Microsoft.VisualStudio.TextTemplating/TextTransformation.cs \
Microsoft.VisualStudio.TextTemplating/ToStringHelper.cs \
Mono.TextTemplating/CompiledTemplate.cs \
Mono.TextTemplating/CrossAppDomainAssemblyResolver.cs \
Mono.TextTemplating/ParsedTemplate.cs \
Mono.TextTemplating/TemplateGenerator.cs \
Mono.TextTemplating/TemplateSettings.cs \
Mono.TextTemplating/TemplatingEngine.cs \
Mono.TextTemplating/Tokeniser.cs
RES =
all: $(ASSEMBLY) $(ASSEMBLY).mdb $(DATA_FILE_BUILD)
$(ASSEMBLY): $(build_sources) $(build_resources) $(DEPS)
mkdir -p $(ADDIN_BUILD)
$(CSC) $(CSC_FLAGS) -debug -out:$@ -target:library $(REFS) $(build_deps) \
$(build_resources:%=/resource:%) $(build_sources)
$(ASSEMBLY).mdb: $(ASSEMBLY)
$(DATA_FILE_BUILD): $(srcdir)$(subst $(ADDIN_BUILD),, $@)
mkdir -p $(ADDIN_BUILD)/Schemas
cp $(srcdir)/$(subst $(ADDIN_BUILD),,$@) $@
check: all
assemblydir = $(MD_ADDIN_DIR)/MonoDevelop.TextTemplating
assembly_DATA = $(ASSEMBLY) $(ASSEMBLY).mdb
CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb
EXTRA_DIST = $(FILES) $(RES)
include $(top_srcdir)/Makefile.include

View file

@ -0,0 +1,43 @@
//
// AssemblyCacheMonitor.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2010 Novell, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Microsoft.VisualStudio.TextTemplating
{
public sealed class AssemblyCacheMonitor : MarshalByRefObject
{
public AssemblyCacheMonitor ()
{
}
public int GetStaleAssembliesCount (TimeSpan assemblyStaleTime)
{
throw new NotImplementedException ();
}
}
}

View file

@ -0,0 +1,63 @@
//
// DirectiveProcessor.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.CodeDom.Compiler;
namespace Microsoft.VisualStudio.TextTemplating
{
public abstract class DirectiveProcessor
{
protected DirectiveProcessor ()
{
}
public virtual void Initialize (ITextTemplatingEngineHost host)
{
if (host == null)
throw new ArgumentNullException ("host");
}
public virtual void StartProcessingRun (CodeDomProvider languageProvider, string templateContents, CompilerErrorCollection errors)
{
if (languageProvider == null)
throw new ArgumentNullException ("languageProvider");
this.Errors = errors;
}
public abstract void FinishProcessingRun ();
public abstract string GetClassCodeForProcessingRun ();
public abstract string[] GetImportsForProcessingRun ();
public abstract string GetPostInitializationCodeForProcessingRun ();
public abstract string GetPreInitializationCodeForProcessingRun ();
public abstract string[] GetReferencesForProcessingRun ();
public abstract bool IsDirectiveSupported (string directiveName);
public abstract void ProcessDirective (string directiveName, IDictionary<string, string> arguments);
protected CompilerErrorCollection Errors { get; private set; }
}
}

View file

@ -0,0 +1,56 @@
//
// DirectiveProcessorException.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Runtime.Serialization;
namespace Microsoft.VisualStudio.TextTemplating
{
[Serializable]
public class DirectiveProcessorException : Exception
{
public DirectiveProcessorException ()
{
}
public DirectiveProcessorException (string message)
: base (message)
{
}
public DirectiveProcessorException (SerializationInfo info, StreamingContext context)
: base (info, context)
{
}
public DirectiveProcessorException (string message, Exception inner)
: base (message, inner)
{
}
}
}

View file

@ -0,0 +1,40 @@
//
// EncodingHelper.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2010 Novell, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Text;
namespace Microsoft.VisualStudio.TextTemplating
{
public static class EncodingHelper
{
public static Encoding GetEncoding (string filePath)
{
throw new NotImplementedException ();
}
}
}

View file

@ -0,0 +1,58 @@
//
// Engine.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.CodeDom;
using System.CodeDom.Compiler;
using Mono.TextTemplating;
namespace Microsoft.VisualStudio.TextTemplating
{
public class Engine : ITextTemplatingEngine
{
TemplatingEngine engine = new TemplatingEngine ();
public Engine ()
{
}
public string ProcessTemplate (string content, ITextTemplatingEngineHost host)
{
return engine.ProcessTemplate (content, host);
}
public string PreprocessTemplate (string content, ITextTemplatingEngineHost host, string className,
string classNamespace, out string language, out string[] references)
{
return engine.PreprocessTemplate (content, host, className, classNamespace, out language, out references);
}
public const string CacheAssembliesOptionString = "CacheAssemblies";
}
}

View file

@ -0,0 +1,84 @@
//
// ITextTemplatingEngineHost.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2009-2010 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Text;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections;
using System.Runtime.Serialization;
namespace Microsoft.VisualStudio.TextTemplating
{
public interface IRecognizeHostSpecific
{
void SetProcessingRunIsHostSpecific (bool hostSpecific);
bool RequiresProcessingRunIsHostSpecific { get; }
}
[CLSCompliant(true)]
public interface ITextTemplatingEngine
{
string ProcessTemplate (string content, ITextTemplatingEngineHost host);
string PreprocessTemplate (string content, ITextTemplatingEngineHost host, string className,
string classNamespace, out string language, out string[] references);
}
[CLSCompliant(true)]
public interface ITextTemplatingEngineHost
{
object GetHostOption (string optionName);
bool LoadIncludeText (string requestFileName, out string content, out string location);
void LogErrors (CompilerErrorCollection errors);
AppDomain ProvideTemplatingAppDomain (string content);
string ResolveAssemblyReference (string assemblyReference);
Type ResolveDirectiveProcessor (string processorName);
string ResolveParameterValue (string directiveId, string processorName, string parameterName);
string ResolvePath (string path);
void SetFileExtension (string extension);
void SetOutputEncoding (Encoding encoding, bool fromOutputDirective);
IList<string> StandardAssemblyReferences { get; }
IList<string> StandardImports { get; }
string TemplateFile { get; }
}
[CLSCompliant(true)]
public interface ITextTemplatingSession :
IEquatable<ITextTemplatingSession>, IEquatable<Guid>, IDictionary<string, Object>,
ICollection<KeyValuePair<string, Object>>,
IEnumerable<KeyValuePair<string, Object>>,
IEnumerable, ISerializable
{
Guid Id { get; }
}
[CLSCompliant(true)]
public interface ITextTemplatingSessionHost
{
ITextTemplatingSession CreateSession ();
ITextTemplatingSession Session { get; set; }
}
}

View file

@ -0,0 +1,268 @@
//
// ParameterDirectiveProcessor.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2010 Novell, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.CodeDom.Compiler;
using System.CodeDom;
using System.IO;
using System.Linq;
using System.Reflection;
namespace Microsoft.VisualStudio.TextTemplating
{
public sealed class ParameterDirectiveProcessor : DirectiveProcessor, IRecognizeHostSpecific
{
CodeDomProvider provider;
bool isCSharp;
bool useMonoHack;
bool hostSpecific;
List<CodeStatement> postStatements = new List<CodeStatement> ();
CodeTypeMemberCollection members = new CodeTypeMemberCollection ();
public ParameterDirectiveProcessor ()
{
}
public override void StartProcessingRun (CodeDomProvider languageProvider, string templateContents, CompilerErrorCollection errors)
{
base.StartProcessingRun (languageProvider, templateContents, errors);
this.provider = languageProvider;
//HACK: Mono as of 2.10.2 doesn't implement GenerateCodeFromMember
if (Type.GetType ("Mono.Runtime") != null)
useMonoHack = true;
if (languageProvider is Microsoft.CSharp.CSharpCodeProvider)
isCSharp = true;
postStatements.Clear ();
members.Clear ();
}
public override void FinishProcessingRun ()
{
var statement = new CodeConditionStatement (
new CodeBinaryOperatorExpression (
new CodePropertyReferenceExpression (
new CodePropertyReferenceExpression (new CodeThisReferenceExpression (), "Errors"), "HasErrors"),
CodeBinaryOperatorType.ValueEquality,
new CodePrimitiveExpression (false)),
postStatements.ToArray ());
postStatements.Clear ();
postStatements.Add (statement);
}
public override string GetClassCodeForProcessingRun ()
{
var options = new CodeGeneratorOptions ();
using (var sw = new StringWriter ()) {
GenerateCodeFromMembers (sw, options);
return Indent (sw.ToString (), " ");
}
}
string Indent (string s, string indent)
{
if (isCSharp)
return Mono.TextTemplating.TemplatingEngine.IndentSnippetText (s, indent);
return s;
}
public override string[] GetImportsForProcessingRun ()
{
return null;
}
public override string GetPostInitializationCodeForProcessingRun ()
{
return Indent (StatementsToCode (postStatements), " ");
}
public override string GetPreInitializationCodeForProcessingRun ()
{
return null;
}
string StatementsToCode (List<CodeStatement> statements)
{
var options = new CodeGeneratorOptions ();
using (var sw = new StringWriter ()) {
foreach (var statement in statements)
provider.GenerateCodeFromStatement (statement, sw, options);
return sw.ToString ();
}
}
public override string[] GetReferencesForProcessingRun ()
{
return null;
}
public override bool IsDirectiveSupported (string directiveName)
{
return directiveName == "parameter";
}
public override void ProcessDirective (string directiveName, IDictionary<string, string> arguments)
{
string name = arguments["name"];
string type = arguments["type"];
if (string.IsNullOrEmpty (name))
throw new DirectiveProcessorException ("Parameter directive has no name argument");
if (string.IsNullOrEmpty (type))
throw new DirectiveProcessorException ("Parameter directive has no type argument");
string fieldName = "_" + name + "Field";
var typeRef = new CodeTypeReference (type);
var thisRef = new CodeThisReferenceExpression ();
var fieldRef = new CodeFieldReferenceExpression (thisRef, fieldName);
var property = new CodeMemberProperty () {
Name = name,
Attributes = MemberAttributes.Public | MemberAttributes.Final,
HasGet = true,
HasSet = false,
Type = typeRef
};
property.GetStatements.Add (new CodeMethodReturnStatement (fieldRef));
members.Add (new CodeMemberField (typeRef, fieldName));
members.Add (property);
string acquiredName = "_" + name + "Acquired";
var valRef = new CodeVariableReferenceExpression ("data");
var namePrimitive = new CodePrimitiveExpression (name);
var sessionRef = new CodePropertyReferenceExpression (thisRef, "Session");
var callContextTypeRefExpr = new CodeTypeReferenceExpression ("System.Runtime.Remoting.Messaging.CallContext");
var nullPrim = new CodePrimitiveExpression (null);
var acquiredVariable = new CodeVariableDeclarationStatement (typeof (bool), acquiredName, new CodePrimitiveExpression (false));
var acquiredVariableRef = new CodeVariableReferenceExpression (acquiredVariable.Name);
this.postStatements.Add (acquiredVariable);
//checks the local called "data" can be cast and assigned to the field, and if successful, sets acquiredVariable to true
var checkCastThenAssignVal = new CodeConditionStatement (
new CodeMethodInvokeExpression (
new CodeTypeOfExpression (typeRef), "IsAssignableFrom", new CodeMethodInvokeExpression (valRef, "GetType")),
new CodeStatement[] {
new CodeAssignStatement (fieldRef, new CodeCastExpression (typeRef, valRef)),
new CodeAssignStatement (acquiredVariableRef, new CodePrimitiveExpression (true)),
},
new CodeStatement[] {
new CodeExpressionStatement (new CodeMethodInvokeExpression (thisRef, "Error",
new CodePrimitiveExpression ("The type '" + type + "' of the parameter '" + name +
"' did not match the type passed to the template"))),
});
//tries to gets the value from the session
var checkSession = new CodeConditionStatement (
new CodeBinaryOperatorExpression (NotNull (sessionRef), CodeBinaryOperatorType.BooleanAnd,
new CodeMethodInvokeExpression (sessionRef, "ContainsKey", namePrimitive)),
new CodeVariableDeclarationStatement (typeof (object), "data", new CodeIndexerExpression (sessionRef, namePrimitive)),
checkCastThenAssignVal);
this.postStatements.Add (checkSession);
//if acquiredVariable is false, tries to gets the value from the host
if (hostSpecific) {
var hostRef = new CodePropertyReferenceExpression (thisRef, "Host");
var checkHost = new CodeConditionStatement (
BooleanAnd (IsFalse (acquiredVariableRef), NotNull (hostRef)),
new CodeVariableDeclarationStatement (typeof (string), "data",
new CodeMethodInvokeExpression (hostRef, "ResolveParameterValue", nullPrim, nullPrim, namePrimitive)),
new CodeConditionStatement (NotNull (valRef), checkCastThenAssignVal));
this.postStatements.Add (checkHost);
}
//if acquiredVariable is false, tries to gets the value from the call context
var checkCallContext = new CodeConditionStatement (
IsFalse (acquiredVariableRef),
new CodeVariableDeclarationStatement (typeof (object), "data",
new CodeMethodInvokeExpression (callContextTypeRefExpr, "LogicalGetData", namePrimitive)),
new CodeConditionStatement (NotNull (valRef), checkCastThenAssignVal));
this.postStatements.Add (checkCallContext);
}
static CodeBinaryOperatorExpression NotNull (CodeExpression reference)
{
return new CodeBinaryOperatorExpression (reference, CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression (null));
}
static CodeBinaryOperatorExpression IsFalse (CodeExpression expr)
{
return new CodeBinaryOperatorExpression (expr, CodeBinaryOperatorType.ValueEquality, new CodePrimitiveExpression (false));
}
static CodeBinaryOperatorExpression BooleanAnd (CodeExpression expr1, CodeExpression expr2)
{
return new CodeBinaryOperatorExpression (expr1, CodeBinaryOperatorType.BooleanAnd, expr2);
}
void IRecognizeHostSpecific.SetProcessingRunIsHostSpecific (bool hostSpecific)
{
this.hostSpecific = hostSpecific;
}
public bool RequiresProcessingRunIsHostSpecific {
get { return false; }
}
void GenerateCodeFromMembers (StringWriter sw, CodeGeneratorOptions options)
{
if (!useMonoHack) {
foreach (CodeTypeMember member in members)
provider.GenerateCodeFromMember (member, sw, options);
}
var cgType = typeof (CodeGenerator);
var cgInit = cgType.GetMethod ("InitOutput", BindingFlags.NonPublic | BindingFlags.Instance);
var cgFieldGen = cgType.GetMethod ("GenerateField", BindingFlags.NonPublic | BindingFlags.Instance);
var cgPropGen = cgType.GetMethod ("GenerateProperty", BindingFlags.NonPublic | BindingFlags.Instance);
#pragma warning disable 0618
var generator = (CodeGenerator) provider.CreateGenerator ();
#pragma warning restore 0618
var dummy = new CodeTypeDeclaration ("Foo");
foreach (CodeTypeMember member in members) {
var f = member as CodeMemberField;
if (f != null) {
cgInit.Invoke (generator, new object[] { sw, options });
cgFieldGen.Invoke (generator, new object[] { f });
continue;
}
var p = member as CodeMemberProperty;
if (p != null) {
cgInit.Invoke (generator, new object[] { sw, options });
cgPropGen.Invoke (generator, new object[] { p, dummy });
continue;
}
}
}
}
}

View file

@ -0,0 +1,196 @@
//
// RequiresProvidesDirectiveProcessor.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.CodeDom.Compiler;
using System.Text;
namespace Microsoft.VisualStudio.TextTemplating
{
public abstract class RequiresProvidesDirectiveProcessor : DirectiveProcessor
{
bool isInProcessingRun;
ITextTemplatingEngineHost host;
StringBuilder preInitBuffer = new StringBuilder ();
StringBuilder postInitBuffer = new StringBuilder ();
StringBuilder codeBuffer = new StringBuilder ();
CodeDomProvider languageProvider;
protected RequiresProvidesDirectiveProcessor ()
{
}
public override void Initialize (ITextTemplatingEngineHost host)
{
base.Initialize (host);
this.host = host;
}
protected abstract void InitializeProvidesDictionary (string directiveName, IDictionary<string, string> providesDictionary);
protected abstract void InitializeRequiresDictionary (string directiveName, IDictionary<string, string> requiresDictionary);
protected abstract string FriendlyName { get; }
protected abstract void GeneratePostInitializationCode (string directiveName, StringBuilder codeBuffer, CodeDomProvider languageProvider,
IDictionary<string, string> requiresArguments, IDictionary<string, string> providesArguments);
protected abstract void GeneratePreInitializationCode (string directiveName, StringBuilder codeBuffer, CodeDomProvider languageProvider,
IDictionary<string, string> requiresArguments, IDictionary<string, string> providesArguments);
protected abstract void GenerateTransformCode (string directiveName, StringBuilder codeBuffer, CodeDomProvider languageProvider,
IDictionary<string, string> requiresArguments, IDictionary<string, string> providesArguments);
protected virtual void PostProcessArguments (string directiveName, IDictionary<string, string> requiresArguments,
IDictionary<string, string> providesArguments)
{
}
public override string GetClassCodeForProcessingRun ()
{
AssertNotProcessing ();
return codeBuffer.ToString ();
}
public override string[] GetImportsForProcessingRun ()
{
AssertNotProcessing ();
return null;
}
public override string[] GetReferencesForProcessingRun ()
{
AssertNotProcessing ();
return null;
}
public override string GetPostInitializationCodeForProcessingRun ()
{
AssertNotProcessing ();
return postInitBuffer.ToString ();
}
public override string GetPreInitializationCodeForProcessingRun ()
{
AssertNotProcessing ();
return preInitBuffer.ToString ();
}
public override void StartProcessingRun (CodeDomProvider languageProvider, string templateContents, CompilerErrorCollection errors)
{
AssertNotProcessing ();
isInProcessingRun = true;
base.StartProcessingRun (languageProvider, templateContents, errors);
this.languageProvider = languageProvider;
codeBuffer.Length = 0;
preInitBuffer.Length = 0;
postInitBuffer.Length = 0;
}
public override void FinishProcessingRun ()
{
isInProcessingRun = false;
}
void AssertNotProcessing ()
{
if (isInProcessingRun)
throw new InvalidOperationException ();
}
//FIXME: handle escaping
IEnumerable<KeyValuePair<string,string>> ParseArgs (string args)
{
var pairs = args.Split (';');
foreach (var p in pairs) {
int eq = p.IndexOf ('=');
var k = p.Substring (0, eq);
var v = p.Substring (eq);
yield return new KeyValuePair<string, string> (k, v);
}
}
public override void ProcessDirective (string directiveName, IDictionary<string, string> arguments)
{
if (directiveName == null)
throw new ArgumentNullException ("directiveName");
if (arguments == null)
throw new ArgumentNullException ("arguments");
var providesDictionary = new Dictionary<string,string> ();
var requiresDictionary = new Dictionary<string,string> ();
string provides;
if (arguments.TryGetValue ("provides", out provides)) {
foreach (var arg in ParseArgs (provides)) {
providesDictionary.Add (arg.Key, arg.Value);
}
}
string requires;
if (arguments.TryGetValue ("requires", out requires)) {
foreach (var arg in ParseArgs (requires)) {
requiresDictionary.Add (arg.Key, arg.Value);
}
}
InitializeRequiresDictionary (directiveName, requiresDictionary);
InitializeProvidesDictionary (directiveName, providesDictionary);
var id = ProvideUniqueId (directiveName, arguments, requiresDictionary, providesDictionary);
foreach (var req in requiresDictionary) {
var val = host.ResolveParameterValue (id, FriendlyName, req.Key);
if (val != null)
requiresDictionary[req.Key] = val;
else if (req.Value == null)
throw new DirectiveProcessorException ("Could not resolve required value '" + req.Key + "'");
}
foreach (var req in providesDictionary) {
var val = host.ResolveParameterValue (id, FriendlyName, req.Key);
if (val != null)
providesDictionary[req.Key] = val;
}
PostProcessArguments (directiveName, requiresDictionary, providesDictionary);
GeneratePreInitializationCode (directiveName, preInitBuffer, languageProvider, requiresDictionary, providesDictionary);
GeneratePostInitializationCode (directiveName, postInitBuffer, languageProvider, requiresDictionary, providesDictionary);
GenerateTransformCode (directiveName, codeBuffer, languageProvider, requiresDictionary, providesDictionary);
}
protected virtual string ProvideUniqueId (string directiveName, IDictionary<string, string> arguments,
IDictionary<string, string> requiresArguments, IDictionary<string, string> providesArguments)
{
return directiveName;
}
protected ITextTemplatingEngineHost Host {
get { return host; }
}
}
}

View file

@ -0,0 +1,71 @@
//
// TextTemplatingSession.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2010 Novell, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Collections;
using System.Runtime.Serialization;
namespace Microsoft.VisualStudio.TextTemplating
{
[Serializable]
public sealed class TextTemplatingSession : Dictionary<string, Object>, ITextTemplatingSession
{
public TextTemplatingSession () : this (Guid.NewGuid ())
{
}
public TextTemplatingSession (Guid id)
{
this.Id = id;
}
public Guid Id {
get; private set;
}
public override int GetHashCode ()
{
return Id.GetHashCode ();
}
public override bool Equals (object obj)
{
var o = obj as TextTemplatingSession;
return o != null && o.Equals (this);
}
public bool Equals (Guid other)
{
return other.Equals (Id);
}
public bool Equals (ITextTemplatingSession other)
{
return other != null && other.Id == this.Id;
}
}
}

View file

@ -0,0 +1,219 @@
//
// TextTransformation.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.VisualStudio.TextTemplating
{
public abstract class TextTransformation : IDisposable
{
Stack<int> indents;
string currentIndent = string.Empty;
CompilerErrorCollection errors;
StringBuilder builder;
bool endsWithNewline;
public TextTransformation ()
{
}
protected internal virtual void Initialize ()
{
}
public abstract string TransformText ();
public virtual IDictionary<string, object> Session { get; set; }
#region Errors
public void Error (string message)
{
Errors.Add (new CompilerError (null, -1, -1, null, message));
}
public void Warning (string message)
{
var err = new CompilerError (null, -1, -1, null, message) {
IsWarning = true,
};
Errors.Add (err);
}
protected internal CompilerErrorCollection Errors {
get {
if (errors == null)
errors = new CompilerErrorCollection ();
return errors;
}
}
Stack<int> Indents {
get {
if (indents == null)
indents = new Stack<int> ();
return indents;
}
}
#endregion
#region Indents
public string PopIndent ()
{
if (Indents.Count == 0)
return "";
int lastPos = currentIndent.Length - Indents.Pop ();
string last = currentIndent.Substring (lastPos);
currentIndent = currentIndent.Substring (0, lastPos);
return last;
}
public void PushIndent (string indent)
{
if (indent == null)
throw new ArgumentNullException ("indent");
Indents.Push (indent.Length);
currentIndent += indent;
}
public void ClearIndent ()
{
currentIndent = string.Empty;
Indents.Clear ();
}
public string CurrentIndent {
get { return currentIndent; }
}
#endregion
#region Writing
protected StringBuilder GenerationEnvironment {
get {
if (builder == null)
builder = new StringBuilder ();
return builder;
}
set {
builder = value;
}
}
public void Write (string textToAppend)
{
if (string.IsNullOrEmpty (textToAppend))
return;
if ((GenerationEnvironment.Length == 0 || endsWithNewline) && CurrentIndent.Length > 0) {
GenerationEnvironment.Append (CurrentIndent);
}
endsWithNewline = false;
char last = textToAppend[textToAppend.Length-1];
if (last == '\n' || last == '\r') {
endsWithNewline = true;
}
if (CurrentIndent.Length == 0) {
GenerationEnvironment.Append (textToAppend);
return;
}
//insert CurrentIndent after every newline (\n, \r, \r\n)
//but if there's one at the end of the string, ignore it, it'll be handled next time thanks to endsWithNewline
int lastNewline = 0;
for (int i = 0; i < textToAppend.Length - 1; i++) {
char c = textToAppend[i];
if (c == '\r') {
if (textToAppend[i + 1] == '\n') {
i++;
if (i == textToAppend.Length - 1)
break;
}
} else if (c != '\n') {
continue;
}
i++;
int len = i - lastNewline;
if (len > 0) {
GenerationEnvironment.Append (textToAppend, lastNewline, i - lastNewline);
}
GenerationEnvironment.Append (CurrentIndent);
lastNewline = i;
}
if (lastNewline > 0)
GenerationEnvironment.Append (textToAppend, lastNewline, textToAppend.Length - lastNewline);
else
GenerationEnvironment.Append (textToAppend);
}
public void Write (string format, params object[] args)
{
Write (string.Format (format, args));
}
public void WriteLine (string textToAppend)
{
Write (textToAppend);
GenerationEnvironment.AppendLine ();
endsWithNewline = true;
}
public void WriteLine (string format, params object[] args)
{
WriteLine (string.Format (format, args));
}
#endregion
#region Dispose
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
protected virtual void Dispose (bool disposing)
{
}
~TextTransformation ()
{
Dispose (false);
}
#endregion
}
}

View file

@ -0,0 +1,69 @@
//
// ToStringHelper.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Reflection;
namespace Microsoft.VisualStudio.TextTemplating
{
public static class ToStringHelper
{
static object [] formatProviderAsParameterArray;
static IFormatProvider formatProvider = System.Globalization.CultureInfo.InvariantCulture;
static ToStringHelper ()
{
formatProviderAsParameterArray = new object[] { formatProvider };
}
public static string ToStringWithCulture (object objectToConvert)
{
if (objectToConvert == null)
throw new ArgumentNullException ("objectToConvert");
IConvertible conv = objectToConvert as IConvertible;
if (conv != null)
return conv.ToString (formatProvider);
var str = objectToConvert as string;
if (str != null)
return str;
//TODO: implement a cache of types and DynamicMethods
MethodInfo mi = objectToConvert.GetType ().GetMethod ("ToString", new Type[] { typeof (IFormatProvider) });
if (mi != null)
return (string) mi.Invoke (objectToConvert, formatProviderAsParameterArray);
return objectToConvert.ToString ();
}
public static IFormatProvider FormatProvider {
get { return (IFormatProvider)formatProviderAsParameterArray[0]; }
set { formatProviderAsParameterArray[0] = formatProvider = value; }
}
}
}

View file

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A2364D6A-00EF-417C-80A6-815726C70032}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Mono.TextTemplating</RootNamespace>
<AssemblyName>Mono.TextTemplating</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Microsoft.VisualStudio.TextTemplating\DirectiveProcessor.cs" />
<Compile Include="Microsoft.VisualStudio.TextTemplating\DirectiveProcessorException.cs" />
<Compile Include="Microsoft.VisualStudio.TextTemplating\Engine.cs" />
<Compile Include="Microsoft.VisualStudio.TextTemplating\RequiresProvidesDirectiveProcessor.cs" />
<Compile Include="Microsoft.VisualStudio.TextTemplating\TextTransformation.cs" />
<Compile Include="Microsoft.VisualStudio.TextTemplating\ToStringHelper.cs" />
<Compile Include="Mono.TextTemplating\CompiledTemplate.cs" />
<Compile Include="Mono.TextTemplating\ParsedTemplate.cs" />
<Compile Include="Mono.TextTemplating\Tokeniser.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Mono.TextTemplating\TemplateGenerator.cs" />
<Compile Include="Mono.TextTemplating\TemplatingEngine.cs" />
<Compile Include="Mono.TextTemplating\TemplateSettings.cs" />
<Compile Include="Mono.TextTemplating\CrossAppDomainAssemblyResolver.cs" />
<Compile Include="Microsoft.VisualStudio.TextTemplating\AssemblyCacheMonitor.cs" />
<Compile Include="Microsoft.VisualStudio.TextTemplating\EncodingHelper.cs" />
<Compile Include="Microsoft.VisualStudio.TextTemplating\ParameterDirectiveProcessor.cs" />
<Compile Include="Microsoft.VisualStudio.TextTemplating\TextTemplatingSession.cs" />
<Compile Include="Microsoft.VisualStudio.TextTemplating\Interfaces.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Folder Include="Microsoft.VisualStudio.TextTemplating\" />
<Folder Include="Mono.TextTemplating\" />
</ItemGroup>
<ProjectExtensions>
<MonoDevelop>
<Properties>
<Policies>
<DotNetNamingPolicy DirectoryNamespaceAssociation="Flat" ResourceNamePolicy="FileName" />
</Policies>
<MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="true" RelativeMakefileName="Makefile.am" BuildTargetName="" CleanTargetName="" SyncReferences="true" IsAutotoolsProject="true" RelativeConfigureInPath="..">
<BuildFilesVar Sync="true" Name="FILES" />
<DeployFilesVar />
<ResourcesVar Sync="true" Name="RES" />
<OthersVar />
<GacRefVar Sync="true" Name="REFS" Prefix="-r:" />
<AsmRefVar Sync="true" Name="REFS" Prefix="-r:" />
<ProjectRefVar Sync="true" Name="DEPS" />
</MonoDevelop.Autotools.MakefileInfo>
</Properties>
</MonoDevelop>
</ProjectExtensions>
</Project>

View file

@ -0,0 +1,113 @@
//
// CompiledTemplate.cs
//
// Author:
// Nathan Baulch <nathan.baulch@gmail.com>
//
// Copyright (c) 2009 Nathan Baulch
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Reflection;
using Microsoft.VisualStudio.TextTemplating;
using System.CodeDom.Compiler;
using System.Globalization;
namespace Mono.TextTemplating
{
public sealed class CompiledTemplate : MarshalByRefObject, IDisposable
{
ITextTemplatingEngineHost host;
TextTransformation tt;
CultureInfo culture;
string[] assemblyFiles;
public CompiledTemplate (ITextTemplatingEngineHost host, CompilerResults results, string fullName, CultureInfo culture,
string[] assemblyFiles)
{
AppDomain.CurrentDomain.AssemblyResolve += ResolveReferencedAssemblies;
this.host = host;
this.culture = culture;
this.assemblyFiles = assemblyFiles;
Load (results, fullName);
}
void Load (CompilerResults results, string fullName)
{
var assembly = results.CompiledAssembly;
Type transformType = assembly.GetType (fullName);
tt = (TextTransformation) Activator.CreateInstance (transformType);
//set the host property if it exists
var hostProp = transformType.GetProperty ("Host", typeof (ITextTemplatingEngineHost));
if (hostProp != null && hostProp.CanWrite)
hostProp.SetValue (tt, host, null);
var sessionHost = host as ITextTemplatingSessionHost;
if (sessionHost != null) {
//FIXME: should we create a session if it's null?
tt.Session = sessionHost.Session;
}
}
public string Process ()
{
tt.Errors.Clear ();
//set the culture
if (culture != null)
ToStringHelper.FormatProvider = culture;
else
ToStringHelper.FormatProvider = CultureInfo.InvariantCulture;
tt.Initialize ();
string output = null;
try {
output = tt.TransformText ();
} catch (Exception ex) {
tt.Error ("Error running transform: " + ex.ToString ());
}
host.LogErrors (tt.Errors);
ToStringHelper.FormatProvider = CultureInfo.InvariantCulture;
return output;
}
System.Reflection.Assembly ResolveReferencedAssemblies (object sender, ResolveEventArgs args)
{
System.Reflection.Assembly asm = null;
foreach (var asmFile in assemblyFiles) {
var name = System.IO.Path.GetFileNameWithoutExtension (asmFile);
if (args.Name.StartsWith (name))
asm = System.Reflection.Assembly.LoadFrom (asmFile);
}
return asm;
}
public void Dispose ()
{
if (host != null) {
host = null;
AppDomain.CurrentDomain.AssemblyResolve -= ResolveReferencedAssemblies;
}
}
}
}

View file

@ -0,0 +1,59 @@
//
// CrossAppDomainAssemblyResolver.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2010 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Mono.TextTemplating
{
[Serializable]
/// <summary>
/// Provides a handler for AssemblyResolve events that looks them up in the domain that created the resolver.
/// </summary>
public class CrossAppDomainAssemblyResolver
{
ParentDomainLookup parent = new ParentDomainLookup ();
public System.Reflection.Assembly Resolve (object sender, ResolveEventArgs args)
{
var location = parent.GetAssemblyPath (args.Name);
if (location != null)
return System.Reflection.Assembly.LoadFrom (location);
return null;
}
class ParentDomainLookup : MarshalByRefObject
{
public string GetAssemblyPath (string name)
{
var assem = System.Reflection.Assembly.Load (name);
if (assem != null)
return assem.Location;
return null;
}
}
}
}

View file

@ -0,0 +1,320 @@
//
// Template.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO;
using Microsoft.VisualStudio.TextTemplating;
namespace Mono.TextTemplating
{
public class ParsedTemplate
{
List<ISegment> segments = new List<ISegment> ();
CompilerErrorCollection errors = new CompilerErrorCollection ();
string rootFileName;
public ParsedTemplate (string rootFileName)
{
this.rootFileName = rootFileName;
}
public List<ISegment> RawSegments {
get { return segments; }
}
public IEnumerable<Directive> Directives {
get {
foreach (ISegment seg in segments) {
Directive dir = seg as Directive;
if (dir != null)
yield return dir;
}
}
}
public IEnumerable<TemplateSegment> Content {
get {
foreach (ISegment seg in segments) {
TemplateSegment ts = seg as TemplateSegment;
if (ts != null)
yield return ts;
}
}
}
public CompilerErrorCollection Errors {
get { return errors; }
}
public static ParsedTemplate FromText (string content, ITextTemplatingEngineHost host)
{
ParsedTemplate template = new ParsedTemplate (host.TemplateFile);
try {
template.Parse (host, new Tokeniser (host.TemplateFile, content));
} catch (ParserException ex) {
template.LogError (ex.Message, ex.Location);
}
return template;
}
public void Parse (ITextTemplatingEngineHost host, Tokeniser tokeniser)
{
Parse (host, tokeniser, true);
}
public void ParseWithoutIncludes (Tokeniser tokeniser)
{
Parse (null, tokeniser, false);
}
void Parse (ITextTemplatingEngineHost host, Tokeniser tokeniser, bool parseIncludes)
{
bool skip = false;
while ((skip || tokeniser.Advance ()) && tokeniser.State != State.EOF) {
skip = false;
ISegment seg = null;
switch (tokeniser.State) {
case State.Block:
if (!String.IsNullOrEmpty (tokeniser.Value))
seg = new TemplateSegment (SegmentType.Block, tokeniser.Value, tokeniser.Location);
break;
case State.Content:
if (!String.IsNullOrEmpty (tokeniser.Value))
seg = new TemplateSegment (SegmentType.Content, tokeniser.Value, tokeniser.Location);
break;
case State.Expression:
if (!String.IsNullOrEmpty (tokeniser.Value))
seg = new TemplateSegment (SegmentType.Expression, tokeniser.Value, tokeniser.Location);
break;
case State.Helper:
if (!String.IsNullOrEmpty (tokeniser.Value))
seg = new TemplateSegment (SegmentType.Helper, tokeniser.Value, tokeniser.Location);
break;
case State.Directive:
Directive directive = null;
string attName = null;
while (!skip && tokeniser.Advance ()) {
switch (tokeniser.State) {
case State.DirectiveName:
if (directive == null) {
directive = new Directive (tokeniser.Value.ToLower (), tokeniser.Location);
directive.TagStartLocation = tokeniser.TagStartLocation;
if (!parseIncludes || directive.Name != "include")
segments.Add (directive);
} else
attName = tokeniser.Value;
break;
case State.DirectiveValue:
if (attName != null && directive != null)
directive.Attributes[attName.ToLower ()] = tokeniser.Value;
else
LogError ("Directive value without name", tokeniser.Location);
attName = null;
break;
case State.Directive:
if (directive != null)
directive.EndLocation = tokeniser.TagEndLocation;
break;
default:
skip = true;
break;
}
}
if (parseIncludes && directive.Name == "include")
Import (host, directive, Path.GetDirectoryName (tokeniser.Location.FileName));
break;
default:
throw new InvalidOperationException ();
}
if (seg != null) {
seg.TagStartLocation = tokeniser.TagStartLocation;
seg.EndLocation = tokeniser.TagEndLocation;
segments.Add (seg);
}
}
}
void Import (ITextTemplatingEngineHost host, Directive includeDirective, string relativeToDirectory)
{
string fileName;
if (includeDirective.Attributes.Count > 1 || !includeDirective.Attributes.TryGetValue ("file", out fileName)) {
LogError ("Unexpected attributes in include directive", includeDirective.StartLocation);
return;
}
//try to resolve path relative to the file that included it
if (!Path.IsPathRooted (fileName)) {
string possible = Path.Combine (relativeToDirectory, fileName);
if (File.Exists (possible))
fileName = possible;
}
string content, resolvedName;
if (host.LoadIncludeText (fileName, out content, out resolvedName))
Parse (host, new Tokeniser (resolvedName, content), true);
else
LogError ("Could not resolve include file '" + fileName + "'.", includeDirective.StartLocation);
}
void LogError (string message, Location location, bool isWarning)
{
CompilerError err = new CompilerError ();
err.ErrorText = message;
if (location.FileName != null) {
err.Line = location.Line;
err.Column = location.Column;
err.FileName = location.FileName ?? string.Empty;
} else {
err.FileName = rootFileName ?? string.Empty;
}
err.IsWarning = isWarning;
errors.Add (err);
}
public void LogError (string message)
{
LogError (message, Location.Empty, false);
}
public void LogWarning (string message)
{
LogError (message, Location.Empty, true);
}
public void LogError (string message, Location location)
{
LogError (message, location, false);
}
public void LogWarning (string message, Location location)
{
LogError (message, location, true);
}
}
public interface ISegment
{
Location StartLocation { get; }
Location EndLocation { get; set; }
Location TagStartLocation {get; set; }
}
public class TemplateSegment : ISegment
{
public TemplateSegment (SegmentType type, string text, Location start)
{
this.Type = type;
this.StartLocation = start;
this.Text = text;
}
public SegmentType Type { get; private set; }
public string Text { get; private set; }
public Location TagStartLocation { get; set; }
public Location StartLocation { get; private set; }
public Location EndLocation { get; set; }
}
public class Directive : ISegment
{
public Directive (string name, Location start)
{
this.Name = name;
this.Attributes = new Dictionary<string, string> ();
this.StartLocation = start;
}
public string Name { get; private set; }
public Dictionary<string,string> Attributes { get; private set; }
public Location TagStartLocation { get; set; }
public Location StartLocation { get; private set; }
public Location EndLocation { get; set; }
public string Extract (string key)
{
string value;
if (!Attributes.TryGetValue (key, out value))
return null;
Attributes.Remove (key);
return value;
}
}
public enum SegmentType
{
Block,
Expression,
Content,
Helper
}
public struct Location : IEquatable<Location>
{
public Location (string fileName, int line, int column) : this()
{
FileName = fileName;
Column = column;
Line = line;
}
public int Line { get; private set; }
public int Column { get; private set; }
public string FileName { get; private set; }
public static Location Empty {
get { return new Location (null, -1, -1); }
}
public Location AddLine ()
{
return new Location (this.FileName, this.Line + 1, 1);
}
public Location AddCol ()
{
return AddCols (1);
}
public Location AddCols (int number)
{
return new Location (this.FileName, this.Line, this.Column + number);
}
public override string ToString ()
{
return string.Format("[{0} ({1},{2})]", FileName, Line, Column);
}
public bool Equals (Location other)
{
return other.Line == Line && other.Column == Column && other.FileName == FileName;
}
}
}

View file

@ -0,0 +1,373 @@
//
// TemplatingHost.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.CodeDom.Compiler;
using System.IO;
using System.Text;
using Microsoft.VisualStudio.TextTemplating;
namespace Mono.TextTemplating
{
public class TemplateGenerator : MarshalByRefObject, ITextTemplatingEngineHost
{
//re-usable
TemplatingEngine engine;
//per-run variables
string inputFile, outputFile;
Encoding encoding;
//host fields
CompilerErrorCollection errors = new CompilerErrorCollection ();
List<string> refs = new List<string> ();
List<string> imports = new List<string> ();
List<string> includePaths = new List<string> ();
List<string> referencePaths = new List<string> ();
//host properties for consumers to access
public CompilerErrorCollection Errors { get { return errors; } }
public List<string> Refs { get { return refs; } }
public List<string> Imports { get { return imports; } }
public List<string> IncludePaths { get { return includePaths; } }
public List<string> ReferencePaths { get { return referencePaths; } }
public string OutputFile { get { return outputFile; } }
public TemplateGenerator ()
{
Refs.Add (typeof (TextTransformation).Assembly.Location);
Refs.Add (typeof(System.Uri).Assembly.Location);
Imports.Add ("System");
}
public CompiledTemplate CompileTemplate (string content)
{
if (String.IsNullOrEmpty (content))
throw new ArgumentNullException ("content");
errors.Clear ();
encoding = Encoding.UTF8;
return Engine.CompileTemplate (content, this);
}
protected TemplatingEngine Engine {
get {
if (engine == null)
engine = new TemplatingEngine ();
return engine;
}
}
public bool ProcessTemplate (string inputFile, string outputFile)
{
if (String.IsNullOrEmpty (inputFile))
throw new ArgumentNullException ("inputFile");
if (String.IsNullOrEmpty (outputFile))
throw new ArgumentNullException ("outputFile");
string content;
try {
content = File.ReadAllText (inputFile);
} catch (IOException ex) {
errors.Clear ();
AddError ("Could not read input file '" + inputFile + "':\n" + ex.ToString ());
return false;
}
string output;
ProcessTemplate (inputFile, content, ref outputFile, out output);
try {
if (!errors.HasErrors)
File.WriteAllText (outputFile, output, encoding);
} catch (IOException ex) {
AddError ("Could not write output file '" + outputFile + "':\n" + ex.ToString ());
}
return !errors.HasErrors;
}
public bool ProcessTemplate (string inputFileName, string inputContent, ref string outputFileName, out string outputContent)
{
errors.Clear ();
encoding = Encoding.UTF8;
this.outputFile = outputFileName;
this.inputFile = inputFileName;
outputContent = Engine.ProcessTemplate (inputContent, this);
outputFileName = this.outputFile;
return !errors.HasErrors;
}
public bool PreprocessTemplate (string inputFile, string className, string classNamespace,
string outputFile, System.Text.Encoding encoding, out string language, out string[] references)
{
language = null;
references = null;
if (string.IsNullOrEmpty (inputFile))
throw new ArgumentNullException ("inputFile");
if (string.IsNullOrEmpty (outputFile))
throw new ArgumentNullException ("outputFile");
string content;
try {
content = File.ReadAllText (inputFile);
} catch (IOException ex) {
errors.Clear ();
AddError ("Could not read input file '" + inputFile + "':\n" + ex.ToString ());
return false;
}
string output;
PreprocessTemplate (inputFile, className, classNamespace, content, out language, out references, out output);
try {
if (!errors.HasErrors)
File.WriteAllText (outputFile, output, encoding);
} catch (IOException ex) {
AddError ("Could not write output file '" + outputFile + "':\n" + ex.ToString ());
}
return !errors.HasErrors;
}
public bool PreprocessTemplate (string inputFileName, string className, string classNamespace, string inputContent,
out string language, out string[] references, out string outputContent)
{
errors.Clear ();
encoding = Encoding.UTF8;
this.inputFile = inputFileName;
outputContent = Engine.PreprocessTemplate (inputContent, this, className, classNamespace, out language, out references);
return !errors.HasErrors;
}
CompilerError AddError (string error)
{
CompilerError err = new CompilerError ();
err.ErrorText = error;
Errors.Add (err);
return err;
}
#region Virtual members
public virtual object GetHostOption (string optionName)
{
return null;
}
public virtual AppDomain ProvideTemplatingAppDomain (string content)
{
return null;
}
//FIXME: implement
protected virtual string ResolveAssemblyReference (string assemblyReference)
{
//foreach (string referencePath in ReferencePaths) {
//
//}
return assemblyReference;
}
protected virtual string ResolveParameterValue (string directiveId, string processorName, string parameterName)
{
var key = new ParameterKey (processorName, directiveId, parameterName);
string value;
if (parameters.TryGetValue (key, out value))
return value;
if (processorName != null || directiveId != null)
return ResolveParameterValue (null, null, parameterName);
return null;
}
protected virtual Type ResolveDirectiveProcessor (string processorName)
{
KeyValuePair<string,string> value;
if (!directiveProcessors.TryGetValue (processorName, out value))
throw new Exception (string.Format ("No directive processor registered as '{0}'", processorName));
var asmPath = ResolveAssemblyReference (value.Value);
if (asmPath == null)
throw new Exception (string.Format ("Could not resolve assembly '{0}' for directive processor '{1}'", value.Value, processorName));
var asm = System.Reflection.Assembly.LoadFrom (asmPath);
return asm.GetType (value.Key, true);
}
protected virtual string ResolvePath (string path)
{
path = System.Environment.ExpandEnvironmentVariables (path);
if (Path.IsPathRooted (path))
return path;
var dir = Path.GetDirectoryName (inputFile);
var test = Path.Combine (dir, path);
if (File.Exists (test))
return test;
return null;
}
#endregion
Dictionary<ParameterKey,string> parameters = new Dictionary<ParameterKey, string> ();
Dictionary<string,KeyValuePair<string,string>> directiveProcessors = new Dictionary<string, KeyValuePair<string,string>> ();
public void AddDirectiveProcessor (string name, string klass, string assembly)
{
directiveProcessors.Add (name, new KeyValuePair<string,string> (klass,assembly));
}
public void AddParameter (string processorName, string directiveName, string parameterName, string value)
{
parameters.Add (new ParameterKey (processorName, directiveName, parameterName), value);
}
protected virtual bool LoadIncludeText (string requestFileName, out string content, out string location)
{
content = "";
location = ResolvePath (requestFileName);
if (location == null) {
foreach (string path in includePaths) {
string f = Path.Combine (path, requestFileName);
if (File.Exists (f)) {
location = f;
break;
}
}
}
if (location == null)
return false;
try {
content = File.ReadAllText (location);
return true;
} catch (IOException ex) {
AddError ("Could not read included file '" + location + "':\n" + ex.ToString ());
}
return false;
}
#region Explicit ITextTemplatingEngineHost implementation
bool ITextTemplatingEngineHost.LoadIncludeText (string requestFileName, out string content, out string location)
{
return LoadIncludeText (requestFileName, out content, out location);
}
void ITextTemplatingEngineHost.LogErrors (CompilerErrorCollection errors)
{
this.errors.AddRange (errors);
}
string ITextTemplatingEngineHost.ResolveAssemblyReference (string assemblyReference)
{
return ResolveAssemblyReference (assemblyReference);
}
string ITextTemplatingEngineHost.ResolveParameterValue (string directiveId, string processorName, string parameterName)
{
return ResolveParameterValue (directiveId, processorName, parameterName);
}
Type ITextTemplatingEngineHost.ResolveDirectiveProcessor (string processorName)
{
return ResolveDirectiveProcessor (processorName);
}
string ITextTemplatingEngineHost.ResolvePath (string path)
{
return ResolvePath (path);
}
void ITextTemplatingEngineHost.SetFileExtension (string extension)
{
extension = extension.TrimStart ('.');
if (Path.HasExtension (outputFile)) {
outputFile = Path.ChangeExtension (outputFile, extension);
} else {
outputFile = outputFile + "." + extension;
}
}
void ITextTemplatingEngineHost.SetOutputEncoding (System.Text.Encoding encoding, bool fromOutputDirective)
{
this.encoding = encoding;
}
IList<string> ITextTemplatingEngineHost.StandardAssemblyReferences {
get { return refs; }
}
IList<string> ITextTemplatingEngineHost.StandardImports {
get { return imports; }
}
string ITextTemplatingEngineHost.TemplateFile {
get { return inputFile; }
}
#endregion
struct ParameterKey : IEquatable<ParameterKey>
{
public ParameterKey (string processorName, string directiveName, string parameterName)
{
this.processorName = processorName ?? "";
this.directiveName = directiveName ?? "";
this.parameterName = parameterName ?? "";
unchecked {
hashCode = this.processorName.GetHashCode ()
^ this.directiveName.GetHashCode ()
^ this.parameterName.GetHashCode ();
}
}
string processorName, directiveName, parameterName;
int hashCode;
public override bool Equals (object obj)
{
return obj != null && obj is ParameterKey && Equals ((ParameterKey)obj);
}
public bool Equals (ParameterKey other)
{
return processorName == other.processorName && directiveName == other.directiveName && parameterName == other.parameterName;
}
public override int GetHashCode ()
{
return hashCode;
}
}
}
}

View file

@ -0,0 +1,75 @@
//
// TemplateSettings.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TextTemplating;
namespace Mono.TextTemplating
{
public class TemplateSettings
{
public TemplateSettings ()
{
Imports = new HashSet<string> ();
Assemblies = new HashSet<string> ();
CustomDirectives = new List<CustomDirective> ();
DirectiveProcessors = new Dictionary<string, DirectiveProcessor> ();
}
public bool HostSpecific { get; set; }
public bool Debug { get; set; }
public string Inherits { get; set; }
public string Name { get; set; }
public string Namespace { get; set; }
public HashSet<string> Imports { get; private set; }
public HashSet<string> Assemblies { get; private set; }
public System.CodeDom.Compiler.CodeDomProvider Provider { get; set; }
public string Language { get; set; }
public string CompilerOptions { get; set; }
public Encoding Encoding { get; set; }
public string Extension { get; set; }
public System.Globalization.CultureInfo Culture { get; set; }
public List<CustomDirective> CustomDirectives { get; private set; }
public Dictionary<string,DirectiveProcessor> DirectiveProcessors { get; private set; }
public bool IncludePreprocessingHelpers { get; set; }
public bool IsPreprocessed { get; set; }
}
public class CustomDirective
{
public CustomDirective (string processorName, Directive directive)
{
this.ProcessorName = processorName;
this.Directive = directive;
}
public string ProcessorName { get; set; }
public Directive Directive { get; set; }
}
}

View file

@ -0,0 +1,963 @@
//
// Engine.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.CodeDom;
using System.CodeDom.Compiler;
using Microsoft.CSharp;
using Microsoft.VisualStudio.TextTemplating;
using System.Linq;
using System.Reflection;
namespace Mono.TextTemplating
{
public class TemplatingEngine : MarshalByRefObject, Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngine
{
public string ProcessTemplate (string content, ITextTemplatingEngineHost host)
{
var tpl = CompileTemplate (content, host);
try {
if (tpl != null)
return tpl.Process ();
return null;
} finally {
if (tpl != null)
tpl.Dispose ();
}
}
public string PreprocessTemplate (string content, ITextTemplatingEngineHost host, string className,
string classNamespace, out string language, out string[] references)
{
if (content == null)
throw new ArgumentNullException ("content");
if (host == null)
throw new ArgumentNullException ("host");
if (className == null)
throw new ArgumentNullException ("className");
if (classNamespace == null)
throw new ArgumentNullException ("classNamespace");
language = null;
references = null;
var pt = ParsedTemplate.FromText (content, host);
if (pt.Errors.HasErrors) {
host.LogErrors (pt.Errors);
return null;
}
var settings = GetSettings (host, pt);
if (pt.Errors.HasErrors) {
host.LogErrors (pt.Errors);
return null;
}
settings.Name = className;
settings.Namespace = classNamespace;
settings.IncludePreprocessingHelpers = string.IsNullOrEmpty (settings.Inherits);
settings.IsPreprocessed = true;
language = settings.Language;
var ccu = GenerateCompileUnit (host, content, pt, settings);
references = ProcessReferences (host, pt, settings).ToArray ();
host.LogErrors (pt.Errors);
if (pt.Errors.HasErrors) {
return null;
}
var options = new CodeGeneratorOptions ();
using (var sw = new StringWriter ()) {
settings.Provider.GenerateCodeFromCompileUnit (ccu, sw, options);
return sw.ToString ();
};
}
public CompiledTemplate CompileTemplate (string content, ITextTemplatingEngineHost host)
{
if (content == null)
throw new ArgumentNullException ("content");
if (host == null)
throw new ArgumentNullException ("host");
var pt = ParsedTemplate.FromText (content, host);
if (pt.Errors.HasErrors) {
host.LogErrors (pt.Errors);
return null;
}
var settings = GetSettings (host, pt);
if (pt.Errors.HasErrors) {
host.LogErrors (pt.Errors);
return null;
}
if (!string.IsNullOrEmpty (settings.Extension)) {
host.SetFileExtension (settings.Extension);
}
if (settings.Encoding != null) {
//FIXME: when is this called with false?
host.SetOutputEncoding (settings.Encoding, true);
}
var ccu = GenerateCompileUnit (host, content, pt, settings);
var references = ProcessReferences (host, pt, settings);
if (pt.Errors.HasErrors) {
host.LogErrors (pt.Errors);
return null;
}
var results = GenerateCode (host, references, settings, ccu);
if (results.Errors.HasErrors) {
host.LogErrors (pt.Errors);
host.LogErrors (results.Errors);
return null;
}
var templateClassFullName = settings.Namespace + "." + settings.Name;
var domain = host.ProvideTemplatingAppDomain (content);
if (domain != null) {
var type = typeof (CompiledTemplate);
var obj = domain.CreateInstanceAndUnwrap (type.Assembly.FullName, type.FullName, false,
BindingFlags.CreateInstance, null,
new object[] { host, results, templateClassFullName, settings.Culture, references.ToArray () },
null, null);
return (CompiledTemplate) obj;
} else {
return new CompiledTemplate (host, results, templateClassFullName, settings.Culture, references.ToArray ());
}
}
static CompilerResults GenerateCode (ITextTemplatingEngineHost host, IEnumerable<string> references, TemplateSettings settings, CodeCompileUnit ccu)
{
var pars = new CompilerParameters () {
GenerateExecutable = false,
CompilerOptions = settings.CompilerOptions,
IncludeDebugInformation = settings.Debug,
GenerateInMemory = false,
};
foreach (var r in references)
pars.ReferencedAssemblies.Add (r);
if (settings.Debug)
pars.TempFiles.KeepFiles = true;
return settings.Provider.CompileAssemblyFromDom (pars, ccu);
}
static HashSet<string> ProcessReferences (ITextTemplatingEngineHost host, ParsedTemplate pt, TemplateSettings settings)
{
var resolved = new HashSet<string> ();
foreach (string assem in settings.Assemblies.Union (host.StandardAssemblyReferences)) {
if (resolved.Contains (assem))
continue;
string resolvedAssem = host.ResolveAssemblyReference (assem);
if (!string.IsNullOrEmpty (resolvedAssem)) {
resolved.Add (resolvedAssem);
} else {
pt.LogError ("Could not resolve assembly reference '" + assem + "'");
return null;
}
}
return resolved;
}
public static TemplateSettings GetSettings (ITextTemplatingEngineHost host, ParsedTemplate pt)
{
var settings = new TemplateSettings ();
foreach (Directive dt in pt.Directives) {
switch (dt.Name) {
case "template":
string val = dt.Extract ("language");
if (val != null)
settings.Language = val;
val = dt.Extract ("debug");
if (val != null)
settings.Debug = string.Compare (val, "true", StringComparison.OrdinalIgnoreCase) == 0;
val = dt.Extract ("inherits");
if (val != null)
settings.Inherits = val;
val = dt.Extract ("culture");
if (val != null) {
System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.GetCultureInfo (val);
if (culture == null)
pt.LogWarning ("Could not find culture '" + val + "'", dt.StartLocation);
else
settings.Culture = culture;
}
val = dt.Extract ("hostspecific");
if (val != null) {
settings.HostSpecific = string.Compare (val, "true", StringComparison.OrdinalIgnoreCase) == 0;
}
val = dt.Extract ("CompilerOptions");
if (val != null) {
settings.CompilerOptions = val;
}
break;
case "assembly":
string name = dt.Extract ("name");
if (name == null)
pt.LogError ("Missing name attribute in assembly directive", dt.StartLocation);
else
settings.Assemblies.Add (name);
break;
case "import":
string namespac = dt.Extract ("namespace");
if (namespac == null)
pt.LogError ("Missing namespace attribute in import directive", dt.StartLocation);
else
settings.Imports.Add (namespac);
break;
case "output":
settings.Extension = dt.Extract ("extension");
string encoding = dt.Extract ("encoding");
if (encoding != null)
settings.Encoding = Encoding.GetEncoding (encoding);
break;
case "include":
throw new InvalidOperationException ("Include is handled in the parser");
case "parameter":
AddDirective (settings, host, "ParameterDirectiveProcessor", dt);
continue;
default:
string processorName = dt.Extract ("Processor");
if (processorName == null)
throw new InvalidOperationException ("Custom directive '" + dt.Name + "' does not specify a processor");
AddDirective (settings, host, processorName, dt);
continue;
}
ComplainExcessAttributes (dt, pt);
}
//initialize the custom processors
foreach (var kv in settings.DirectiveProcessors) {
kv.Value.Initialize (host);
var hs = kv.Value as IRecognizeHostSpecific;
if (hs == null)
continue;
if (hs.RequiresProcessingRunIsHostSpecific && !settings.HostSpecific) {
settings.HostSpecific = true;
pt.LogWarning ("Directive processor '" + kv.Key + "' requires hostspecific=true, forcing on.");
}
hs.SetProcessingRunIsHostSpecific (settings.HostSpecific);
}
if (settings.Name == null)
settings.Name = string.Format ("GeneratedTextTransformation{0:x}", new System.Random ().Next ());
if (settings.Namespace == null)
settings.Namespace = typeof (TextTransformation).Namespace;
//resolve the CodeDOM provider
if (String.IsNullOrEmpty (settings.Language)) {
pt.LogError ("No language was specified for the template");
return settings;
}
if (settings.Language == "C#v3.5") {
Dictionary<string, string> providerOptions = new Dictionary<string, string> ();
providerOptions.Add ("CompilerVersion", "v3.5");
settings.Provider = new CSharpCodeProvider (providerOptions);
}
else {
settings.Provider = CodeDomProvider.CreateProvider (settings.Language);
}
if (settings.Provider == null) {
pt.LogError ("A provider could not be found for the language '" + settings.Language + "'");
return settings;
}
return settings;
}
public static string IndentSnippetText (string text, string indent)
{
var builder = new StringBuilder (text.Length);
builder.Append (indent);
int lastNewline = 0;
for (int i = 0; i < text.Length - 1; i++) {
char c = text[i];
if (c == '\r') {
if (text[i + 1] == '\n') {
i++;
if (i == text.Length - 1)
break;
}
} else if (c != '\n') {
continue;
}
i++;
int len = i - lastNewline;
if (len > 0) {
builder.Append (text, lastNewline, i - lastNewline);
}
builder.Append (indent);
lastNewline = i;
}
if (lastNewline > 0)
builder.Append (text, lastNewline, text.Length - lastNewline);
else
builder.Append (text);
return builder.ToString ();
}
static void AddDirective (TemplateSettings settings, ITextTemplatingEngineHost host, string processorName, Directive directive)
{
DirectiveProcessor processor;
if (!settings.DirectiveProcessors.TryGetValue (processorName, out processor)) {
switch (processorName) {
case "ParameterDirectiveProcessor":
processor = new ParameterDirectiveProcessor ();
break;
default:
Type processorType = host.ResolveDirectiveProcessor (processorName);
processor = (DirectiveProcessor) Activator.CreateInstance (processorType);
break;
}
if (!processor.IsDirectiveSupported (directive.Name))
throw new InvalidOperationException ("Directive processor '" + processorName + "' does not support directive '" + directive.Name + "'");
settings.DirectiveProcessors [processorName] = processor;
}
settings.CustomDirectives.Add (new CustomDirective (processorName, directive));
}
static bool ComplainExcessAttributes (Directive dt, ParsedTemplate pt)
{
if (dt.Attributes.Count == 0)
return false;
StringBuilder sb = new StringBuilder ("Unknown attributes ");
bool first = true;
foreach (string key in dt.Attributes.Keys) {
if (!first) {
sb.Append (", ");
} else {
first = false;
}
sb.Append (key);
}
sb.Append (" found in ");
sb.Append (dt.Name);
sb.Append (" directive.");
pt.LogWarning (sb.ToString (), dt.StartLocation);
return false;
}
static void ProcessDirectives (ITextTemplatingEngineHost host, string content, ParsedTemplate pt, TemplateSettings settings)
{
foreach (var processor in settings.DirectiveProcessors.Values) {
processor.StartProcessingRun (settings.Provider, content, pt.Errors);
}
foreach (var dt in settings.CustomDirectives) {
var processor = settings.DirectiveProcessors[dt.ProcessorName];
if (processor is RequiresProvidesDirectiveProcessor)
throw new NotImplementedException ("RequiresProvidesDirectiveProcessor");
processor.ProcessDirective (dt.Directive.Name, dt.Directive.Attributes);
}
foreach (var processor in settings.DirectiveProcessors.Values) {
processor.FinishProcessingRun ();
var imports = processor.GetImportsForProcessingRun ();
if (imports != null)
settings.Imports.UnionWith (imports);
var references = processor.GetReferencesForProcessingRun ();
if (references != null)
settings.Assemblies.UnionWith (references);
}
}
public static CodeCompileUnit GenerateCompileUnit (ITextTemplatingEngineHost host, string content, ParsedTemplate pt, TemplateSettings settings)
{
ProcessDirectives (host, content, pt, settings);
//prep the compile unit
var ccu = new CodeCompileUnit ();
var namespac = new CodeNamespace (settings.Namespace);
ccu.Namespaces.Add (namespac);
foreach (string ns in settings.Imports.Union (host.StandardImports))
namespac.Imports.Add (new CodeNamespaceImport (ns));
//prep the type
var type = new CodeTypeDeclaration (settings.Name);
type.IsPartial = true;
if (!string.IsNullOrEmpty (settings.Inherits)) {
type.BaseTypes.Add (new CodeTypeReference (settings.Inherits));
} else if (!settings.IncludePreprocessingHelpers) {
type.BaseTypes.Add (TypeRef<TextTransformation> ());
} else {
type.BaseTypes.Add (new CodeTypeReference (settings.Name + "Base"));
}
namespac.Types.Add (type);
//prep the transform method
var transformMeth = new CodeMemberMethod () {
Name = "TransformText",
ReturnType = new CodeTypeReference (typeof (String)),
Attributes = MemberAttributes.Public,
};
if (!settings.IncludePreprocessingHelpers)
transformMeth.Attributes |= MemberAttributes.Override;
transformMeth.Statements.Add (new CodeAssignStatement (
new CodePropertyReferenceExpression (new CodeThisReferenceExpression (), "GenerationEnvironment"),
new CodePrimitiveExpression (null)));
CodeExpression toStringHelper;
if (settings.IsPreprocessed) {
toStringHelper = new CodePropertyReferenceExpression (new CodeThisReferenceExpression (), "ToStringHelper");
} else {
toStringHelper = new CodeTypeReferenceExpression (
new CodeTypeReference (typeof (ToStringHelper), CodeTypeReferenceOptions.GlobalReference));
}
//method references that will need to be used multiple times
var writeMeth = new CodeMethodReferenceExpression (new CodeThisReferenceExpression (), "Write");
var toStringMeth = new CodeMethodReferenceExpression (toStringHelper, "ToStringWithCulture");
bool helperMode = false;
//build the code from the segments
foreach (TemplateSegment seg in pt.Content) {
CodeStatement st = null;
var location = new CodeLinePragma (seg.StartLocation.FileName ?? host.TemplateFile, seg.StartLocation.Line);
switch (seg.Type) {
case SegmentType.Block:
if (helperMode)
//TODO: are blocks permitted after helpers?
throw new ParserException ("Blocks are not permitted after helpers", seg.StartLocation);
st = new CodeSnippetStatement (seg.Text);
break;
case SegmentType.Expression:
st = new CodeExpressionStatement (
new CodeMethodInvokeExpression (writeMeth,
new CodeMethodInvokeExpression (toStringMeth, new CodeSnippetExpression (seg.Text))));
break;
case SegmentType.Content:
st = new CodeExpressionStatement (new CodeMethodInvokeExpression (writeMeth, new CodePrimitiveExpression (seg.Text)));
break;
case SegmentType.Helper:
type.Members.Add (new CodeSnippetTypeMember (seg.Text) { LinePragma = location });
helperMode = true;
break;
default:
throw new InvalidOperationException ();
}
if (st != null) {
if (helperMode) {
//convert the statement into a snippet member and attach it to the top level type
//TODO: is there a way to do this for languages that use indentation for blocks, e.g. python?
using (var writer = new StringWriter ()) {
settings.Provider.GenerateCodeFromStatement (st, writer, null);
type.Members.Add (new CodeSnippetTypeMember (writer.ToString ()) { LinePragma = location });
}
} else {
st.LinePragma = location;
transformMeth.Statements.Add (st);
continue;
}
}
}
//complete the transform method
transformMeth.Statements.Add (new CodeMethodReturnStatement (
new CodeMethodInvokeExpression (
new CodePropertyReferenceExpression (
new CodeThisReferenceExpression (),
"GenerationEnvironment"),
"ToString")));
type.Members.Add (transformMeth);
//class code from processors
foreach (var processor in settings.DirectiveProcessors.Values) {
string classCode = processor.GetClassCodeForProcessingRun ();
if (classCode != null)
type.Members.Add (new CodeSnippetTypeMember (classCode));
}
//generate the Host property if needed
if (settings.HostSpecific) {
GenerateHostProperty (type, settings);
}
GenerateInitializationMethod (type, settings);
if (settings.IncludePreprocessingHelpers) {
var baseClass = new CodeTypeDeclaration (settings.Name + "Base");
GenerateProcessingHelpers (baseClass, settings);
AddToStringHelper (baseClass, settings);
namespac.Types.Add (baseClass);
}
return ccu;
}
static void GenerateHostProperty (CodeTypeDeclaration type, TemplateSettings settings)
{
var hostField = new CodeMemberField (TypeRef<ITextTemplatingEngineHost> (), "hostValue");
hostField.Attributes = (hostField.Attributes & ~MemberAttributes.AccessMask) | MemberAttributes.Private;
type.Members.Add (hostField);
var hostProp = GenerateGetterSetterProperty ("Host", hostField);
hostProp.Attributes = MemberAttributes.Public | MemberAttributes.Final;
type.Members.Add (hostProp);
}
static void GenerateInitializationMethod (CodeTypeDeclaration type, TemplateSettings settings)
{
//initialization method
var initializeMeth = new CodeMemberMethod () {
Name = "Initialize",
ReturnType = new CodeTypeReference (typeof (void), CodeTypeReferenceOptions.GlobalReference),
Attributes = MemberAttributes.Family
};
if (!settings.IncludePreprocessingHelpers)
initializeMeth.Attributes |= MemberAttributes.Override;
//pre-init code from processors
foreach (var processor in settings.DirectiveProcessors.Values) {
string code = processor.GetPreInitializationCodeForProcessingRun ();
if (code != null)
initializeMeth.Statements.Add (new CodeSnippetStatement (code));
}
//base call
if (!settings.IncludePreprocessingHelpers) {
initializeMeth.Statements.Add (
new CodeMethodInvokeExpression (
new CodeMethodReferenceExpression (
new CodeBaseReferenceExpression (),
"Initialize")));
}
//post-init code from processors
foreach (var processor in settings.DirectiveProcessors.Values) {
string code = processor.GetPostInitializationCodeForProcessingRun ();
if (code != null)
initializeMeth.Statements.Add (new CodeSnippetStatement (code));
}
type.Members.Add (initializeMeth);
}
static void GenerateProcessingHelpers (CodeTypeDeclaration type, TemplateSettings settings)
{
var thisRef = new CodeThisReferenceExpression ();
var sbTypeRef = TypeRef<StringBuilder> ();
var sessionField = PrivateField (TypeRef<IDictionary<string,object>> (), "session");
var sessionProp = GenerateGetterSetterProperty ("Session", sessionField);
sessionProp.Attributes = MemberAttributes.Public;
var builderField = PrivateField (sbTypeRef, "builder");
var builderFieldRef = new CodeFieldReferenceExpression (thisRef, builderField.Name);
var generationEnvironmentProp = GenerateGetterSetterProperty ("GenerationEnvironment", builderField);
AddPropertyGetterInitializationIfFieldIsNull (generationEnvironmentProp, builderFieldRef, TypeRef<StringBuilder> ());
type.Members.Add (builderField);
type.Members.Add (sessionField);
type.Members.Add (sessionProp);
type.Members.Add (generationEnvironmentProp);
AddErrorHelpers (type, settings);
AddIndentHelpers (type, settings);
AddWriteHelpers (type, settings);
}
static void AddPropertyGetterInitializationIfFieldIsNull (CodeMemberProperty property, CodeFieldReferenceExpression fieldRef, CodeTypeReference typeRef)
{
var fieldInit = FieldInitializationIfNull (fieldRef, typeRef);
property.GetStatements.Insert (0, fieldInit);
}
static CodeConditionStatement FieldInitializationIfNull (CodeFieldReferenceExpression fieldRef, CodeTypeReference typeRef)
{
return new CodeConditionStatement (
new CodeBinaryOperatorExpression (fieldRef,
CodeBinaryOperatorType.ValueEquality, new CodePrimitiveExpression (null)),
new CodeAssignStatement (fieldRef, new CodeObjectCreateExpression (typeRef)));
}
static void AddErrorHelpers (CodeTypeDeclaration type, TemplateSettings settings)
{
var cecTypeRef = TypeRef<CompilerErrorCollection> ();
var thisRef = new CodeThisReferenceExpression ();
var stringTypeRef = TypeRef<string> ();
var nullPrim = new CodePrimitiveExpression (null);
var minusOnePrim = new CodePrimitiveExpression (-1);
var errorsField = PrivateField (cecTypeRef, "errors");
var errorsFieldRef = new CodeFieldReferenceExpression (thisRef, errorsField.Name);
var errorsProp = GenerateGetterProperty ("Errors", errorsField);
errorsProp.Attributes = MemberAttributes.Family | MemberAttributes.Final;
errorsProp.GetStatements.Insert (0, FieldInitializationIfNull (errorsFieldRef, TypeRef<CompilerErrorCollection>()));
var errorsPropRef = new CodePropertyReferenceExpression (new CodeThisReferenceExpression (), "Errors");
var compilerErrorTypeRef = TypeRef<CompilerError> ();
var errorMeth = new CodeMemberMethod () {
Name = "Error",
Attributes = MemberAttributes.Public | MemberAttributes.Final,
};
errorMeth.Parameters.Add (new CodeParameterDeclarationExpression (stringTypeRef, "message"));
errorMeth.Statements.Add (new CodeMethodInvokeExpression (errorsPropRef, "Add",
new CodeObjectCreateExpression (compilerErrorTypeRef, nullPrim, minusOnePrim, minusOnePrim, nullPrim,
new CodeArgumentReferenceExpression ("message"))));
var warningMeth = new CodeMemberMethod () {
Name = "Warning",
Attributes = MemberAttributes.Public | MemberAttributes.Final,
};
warningMeth.Parameters.Add (new CodeParameterDeclarationExpression (stringTypeRef, "message"));
warningMeth.Statements.Add (new CodeVariableDeclarationStatement (compilerErrorTypeRef, "val",
new CodeObjectCreateExpression (compilerErrorTypeRef, nullPrim, minusOnePrim, minusOnePrim, nullPrim,
new CodeArgumentReferenceExpression ("message"))));
warningMeth.Statements.Add (new CodeAssignStatement (new CodePropertyReferenceExpression (
new CodeVariableReferenceExpression ("val"), "IsWarning"), new CodePrimitiveExpression (true)));
warningMeth.Statements.Add (new CodeMethodInvokeExpression (errorsPropRef, "Add",
new CodeVariableReferenceExpression ("val")));
type.Members.Add (errorsField);
type.Members.Add (errorMeth);
type.Members.Add (warningMeth);
type.Members.Add (errorsProp);
}
static void AddIndentHelpers (CodeTypeDeclaration type, TemplateSettings settings)
{
var stringTypeRef = TypeRef<string> ();
var thisRef = new CodeThisReferenceExpression ();
var zeroPrim = new CodePrimitiveExpression (0);
var stringEmptyRef = new CodeFieldReferenceExpression (new CodeTypeReferenceExpression (stringTypeRef), "Empty");
var intTypeRef = TypeRef<int> ();
var stackIntTypeRef = TypeRef<Stack<int>> ();
var indentsField = PrivateField (stackIntTypeRef, "indents");
var indentsFieldRef = new CodeFieldReferenceExpression (thisRef, indentsField.Name);
var indentsProp = GenerateGetterProperty ("Indents", indentsField);
indentsProp.Attributes = MemberAttributes.Private;
AddPropertyGetterInitializationIfFieldIsNull (indentsProp, indentsFieldRef, TypeRef<Stack<int>> ());
var indentsPropRef = new CodeFieldReferenceExpression (thisRef, indentsProp.Name);
var currentIndentField = PrivateField (stringTypeRef, "currentIndent");
currentIndentField.InitExpression = stringEmptyRef;
var currentIndentFieldRef = new CodeFieldReferenceExpression (thisRef, currentIndentField.Name);
var popIndentMeth = new CodeMemberMethod () {
Name = "PopIndent",
ReturnType = stringTypeRef,
Attributes = MemberAttributes.Public | MemberAttributes.Final,
};
popIndentMeth.Statements.Add (new CodeConditionStatement (
new CodeBinaryOperatorExpression (new CodePropertyReferenceExpression (indentsPropRef, "Count"),
CodeBinaryOperatorType.ValueEquality, zeroPrim),
new CodeMethodReturnStatement (stringEmptyRef)));
popIndentMeth.Statements.Add (new CodeVariableDeclarationStatement (intTypeRef, "lastPos",
new CodeBinaryOperatorExpression (
new CodePropertyReferenceExpression (currentIndentFieldRef, "Length"),
CodeBinaryOperatorType.Subtract,
new CodeMethodInvokeExpression (indentsPropRef, "Pop"))));
popIndentMeth.Statements.Add (new CodeVariableDeclarationStatement (stringTypeRef, "last",
new CodeMethodInvokeExpression (currentIndentFieldRef, "Substring", new CodeVariableReferenceExpression ("lastPos"))));
popIndentMeth.Statements.Add (new CodeAssignStatement (currentIndentFieldRef,
new CodeMethodInvokeExpression (currentIndentFieldRef, "Substring", zeroPrim, new CodeVariableReferenceExpression ("lastPos"))));
popIndentMeth.Statements.Add (new CodeMethodReturnStatement (new CodeVariableReferenceExpression ("last")));
var pushIndentMeth = new CodeMemberMethod () {
Name = "PushIndent",
Attributes = MemberAttributes.Public | MemberAttributes.Final,
};
pushIndentMeth.Parameters.Add (new CodeParameterDeclarationExpression (stringTypeRef, "indent"));
pushIndentMeth.Statements.Add (new CodeMethodInvokeExpression (indentsPropRef, "Push",
new CodePropertyReferenceExpression (new CodeArgumentReferenceExpression ("indent"), "Length")));
pushIndentMeth.Statements.Add (new CodeAssignStatement (currentIndentFieldRef,
new CodeBinaryOperatorExpression (currentIndentFieldRef, CodeBinaryOperatorType.Add, new CodeArgumentReferenceExpression ("indent"))));
var clearIndentMeth = new CodeMemberMethod () {
Name = "ClearIndent",
Attributes = MemberAttributes.Public | MemberAttributes.Final,
};
clearIndentMeth.Statements.Add (new CodeAssignStatement (currentIndentFieldRef, stringEmptyRef));
clearIndentMeth.Statements.Add (new CodeMethodInvokeExpression (indentsPropRef, "Clear"));
var currentIndentProp = GenerateGetterProperty ("CurrentIndent", currentIndentField);
type.Members.Add (currentIndentField);
type.Members.Add (indentsField);
type.Members.Add (popIndentMeth);
type.Members.Add (pushIndentMeth);
type.Members.Add (clearIndentMeth);
type.Members.Add (currentIndentProp);
type.Members.Add (indentsProp);
}
static void AddWriteHelpers (CodeTypeDeclaration type, TemplateSettings settings)
{
var stringTypeRef = TypeRef<string> ();
var thisRef = new CodeThisReferenceExpression ();
var genEnvPropRef = new CodePropertyReferenceExpression (thisRef, "GenerationEnvironment");
var currentIndentFieldRef = new CodeFieldReferenceExpression (thisRef, "currentIndent");
var textToAppendParam = new CodeParameterDeclarationExpression (stringTypeRef, "textToAppend");
var formatParam = new CodeParameterDeclarationExpression (stringTypeRef, "format");
var argsParam = new CodeParameterDeclarationExpression (TypeRef<object[]> (), "args");
argsParam.CustomAttributes.Add (new CodeAttributeDeclaration (TypeRef<System.ParamArrayAttribute> ()));
var textToAppendParamRef = new CodeArgumentReferenceExpression ("textToAppend");
var formatParamRef = new CodeArgumentReferenceExpression ("format");
var argsParamRef = new CodeArgumentReferenceExpression ("args");
var writeMeth = new CodeMemberMethod () {
Name = "Write",
Attributes = MemberAttributes.Public | MemberAttributes.Final,
};
writeMeth.Parameters.Add (textToAppendParam);
writeMeth.Statements.Add (new CodeMethodInvokeExpression (genEnvPropRef, "Append", new CodeArgumentReferenceExpression ("textToAppend")));
var writeArgsMeth = new CodeMemberMethod () {
Name = "Write",
Attributes = MemberAttributes.Public | MemberAttributes.Final,
};
writeArgsMeth.Parameters.Add (formatParam);
writeArgsMeth.Parameters.Add (argsParam);
writeArgsMeth.Statements.Add (new CodeMethodInvokeExpression (genEnvPropRef, "AppendFormat", formatParamRef, argsParamRef));
var writeLineMeth = new CodeMemberMethod () {
Name = "WriteLine",
Attributes = MemberAttributes.Public | MemberAttributes.Final,
};
writeLineMeth.Parameters.Add (textToAppendParam);
writeLineMeth.Statements.Add (new CodeMethodInvokeExpression (genEnvPropRef, "Append", currentIndentFieldRef));
writeLineMeth.Statements.Add (new CodeMethodInvokeExpression (genEnvPropRef, "AppendLine", textToAppendParamRef));
var writeLineArgsMeth = new CodeMemberMethod () {
Name = "WriteLine",
Attributes = MemberAttributes.Public | MemberAttributes.Final,
};
writeLineArgsMeth.Parameters.Add (formatParam);
writeLineArgsMeth.Parameters.Add (argsParam);
writeLineArgsMeth.Statements.Add (new CodeMethodInvokeExpression (genEnvPropRef, "Append", currentIndentFieldRef));
writeLineArgsMeth.Statements.Add (new CodeMethodInvokeExpression (genEnvPropRef, "AppendFormat", formatParamRef, argsParamRef));
writeLineArgsMeth.Statements.Add (new CodeMethodInvokeExpression (genEnvPropRef, "AppendLine"));
type.Members.Add (writeMeth);
type.Members.Add (writeArgsMeth);
type.Members.Add (writeLineMeth);
type.Members.Add (writeLineArgsMeth);
}
static void AddToStringHelper (CodeTypeDeclaration type, TemplateSettings settings)
{
var helperCls = new CodeTypeDeclaration ("ToStringInstanceHelper") {
IsClass = true,
TypeAttributes = System.Reflection.TypeAttributes.NestedPublic,
};
var formatProviderField = PrivateField (TypeRef<IFormatProvider> (), "formatProvider");
formatProviderField.InitExpression = new CodePropertyReferenceExpression (
new CodeTypeReferenceExpression (TypeRef<System.Globalization.CultureInfo> ()), "InvariantCulture");
var formatProviderFieldRef = new CodeFieldReferenceExpression (new CodeThisReferenceExpression (), formatProviderField.Name);
var formatProviderProp = GenerateGetterSetterProperty ("FormatProvider", formatProviderField);
AddSetterNullCheck (formatProviderProp, formatProviderFieldRef);
helperCls.Members.Add (formatProviderField);
helperCls.Members.Add (formatProviderProp);
var meth = new CodeMemberMethod () {
Name = "ToStringWithCulture",
Attributes = MemberAttributes.Public | MemberAttributes.Final,
ReturnType = TypeRef<string> (),
};
meth.Parameters.Add (new CodeParameterDeclarationExpression (TypeRef<object> (), "objectToConvert"));
var paramRef = new CodeArgumentReferenceExpression ("objectToConvert");
meth.Statements.Add (NullCheck (paramRef, paramRef.ParameterName));
var typeLocal = new CodeVariableDeclarationStatement (TypeRef<Type> (), "type", new CodeMethodInvokeExpression (paramRef, "GetType"));
var typeLocalRef = new CodeVariableReferenceExpression (typeLocal.Name);
meth.Statements.Add (typeLocal);
var iConvertibleTypeLocal = new CodeVariableDeclarationStatement (TypeRef<Type> (), "iConvertibleType",
new CodeTypeOfExpression (TypeRef<IConvertible> ()));
var iConvertibleTypeLocalRef = new CodeVariableReferenceExpression (iConvertibleTypeLocal.Name);
meth.Statements.Add (iConvertibleTypeLocal);
meth.Statements.Add (new CodeConditionStatement (
new CodeMethodInvokeExpression (iConvertibleTypeLocalRef, "IsAssignableFrom", typeLocalRef),
new CodeMethodReturnStatement (new CodeMethodInvokeExpression (
new CodeCastExpression (TypeRef<IConvertible> (), paramRef), "ToString", formatProviderFieldRef))));
var methInfoLocal = new CodeVariableDeclarationStatement (TypeRef<MethodInfo> (), "methInfo",
new CodeMethodInvokeExpression (typeLocalRef, "GetMethod",
new CodePrimitiveExpression ("ToString"),
new CodeArrayCreateExpression (TypeRef<Type> (), new CodeExpression [] { iConvertibleTypeLocalRef })));
meth.Statements.Add (methInfoLocal);
var methInfoLocalRef = new CodeVariableReferenceExpression (methInfoLocal.Name);
meth.Statements.Add (new CodeConditionStatement (NotNull (methInfoLocalRef),
new CodeMethodReturnStatement (new CodeCastExpression (TypeRef<string> (),
new CodeMethodInvokeExpression (
methInfoLocalRef, "Invoke", paramRef,
new CodeArrayCreateExpression (TypeRef<object> (), new CodeExpression [] { formatProviderFieldRef } ))))));
meth.Statements.Add (new CodeMethodReturnStatement (new CodeMethodInvokeExpression (paramRef, "ToString")));
helperCls.Members.Add (meth);
var helperFieldName = settings.Provider.CreateValidIdentifier ("_toStringHelper");
var helperField = PrivateField (new CodeTypeReference (helperCls.Name), helperFieldName);
helperField.InitExpression = new CodeObjectCreateExpression (helperField.Type);
type.Members.Add (helperField);
type.Members.Add (GenerateGetterProperty ("ToStringHelper", helperField));
type.Members.Add (helperCls);
}
#region CodeDom helpers
static CodeTypeReference TypeRef<T> ()
{
return new CodeTypeReference (typeof (T), CodeTypeReferenceOptions.GlobalReference);
}
static CodeMemberProperty GenerateGetterSetterProperty (string propertyName, CodeMemberField field)
{
var prop = new CodeMemberProperty () {
Name = propertyName,
Attributes = MemberAttributes.Public | MemberAttributes.Final,
Type = field.Type
};
var fieldRef = new CodeFieldReferenceExpression (new CodeThisReferenceExpression (), field.Name);
AddGetter (prop, fieldRef);
AddSetter (prop, fieldRef);
return prop;
}
static CodeMemberProperty GenerateGetterProperty (string propertyName, CodeMemberField field)
{
var prop = new CodeMemberProperty () {
Name = propertyName,
Attributes = MemberAttributes.Public | MemberAttributes.Final,
HasSet = false,
Type = field.Type
};
var fieldRef = new CodeFieldReferenceExpression (new CodeThisReferenceExpression (), field.Name);
AddGetter (prop, fieldRef);
return prop;
}
static void AddSetter (CodeMemberProperty property, CodeFieldReferenceExpression fieldRef)
{
property.HasSet = true;
property.SetStatements.Add (new CodeAssignStatement (fieldRef, new CodePropertySetValueReferenceExpression ()));
}
static void AddGetter (CodeMemberProperty property, CodeFieldReferenceExpression fieldRef)
{
property.HasGet = true;
property.GetStatements.Add (new CodeMethodReturnStatement (fieldRef));
}
static void MakeGetterLazy (CodeMemberProperty property, CodeFieldReferenceExpression fieldRef, CodeExpression initExpression)
{
property.GetStatements.Insert (0, new CodeConditionStatement (
NotNull (fieldRef),
new CodeAssignStatement (fieldRef, initExpression))
);
}
static void AddSetterNullCheck (CodeMemberProperty property, CodeFieldReferenceExpression fieldRef)
{
property.SetStatements.Insert (0, NullCheck (fieldRef, fieldRef.FieldName));
}
static CodeStatement NullCheck (CodeExpression expr, string exceptionMessage)
{
return new CodeConditionStatement (
IsNull (expr),
new CodeThrowExceptionStatement (new CodeObjectCreateExpression (
new CodeTypeReference (typeof (ArgumentNullException), CodeTypeReferenceOptions.GlobalReference),
new CodePrimitiveExpression (exceptionMessage)))
);
}
static CodeBinaryOperatorExpression NotNull (CodeExpression reference)
{
return new CodeBinaryOperatorExpression (reference, CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression (null));
}
static CodeBinaryOperatorExpression IsNull (CodeExpression reference)
{
return new CodeBinaryOperatorExpression (reference, CodeBinaryOperatorType.ValueEquality, new CodePrimitiveExpression (null));
}
static CodeBinaryOperatorExpression IsFalse (CodeExpression expr)
{
return new CodeBinaryOperatorExpression (expr, CodeBinaryOperatorType.ValueEquality, new CodePrimitiveExpression (false));
}
static CodeBinaryOperatorExpression BooleanAnd (CodeExpression expr1, CodeExpression expr2)
{
return new CodeBinaryOperatorExpression (expr1, CodeBinaryOperatorType.BooleanAnd, expr2);
}
static CodeStatement ArgNullCheck (CodeExpression value, params CodeExpression[] argNullExcArgs)
{
return new CodeConditionStatement (
new CodeBinaryOperatorExpression (value,
CodeBinaryOperatorType.ValueEquality, new CodePrimitiveExpression (null)),
new CodeThrowExceptionStatement (new CodeObjectCreateExpression (typeof (ArgumentNullException), argNullExcArgs)));
}
static CodeMemberField PrivateField (CodeTypeReference typeRef, string name)
{
return new CodeMemberField (typeRef, name) {
Attributes = MemberAttributes.Private
};
}
#endregion
}
}

View file

@ -0,0 +1,295 @@
//
// Tokeniser.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.IO;
using System.Diagnostics;
namespace Mono.TextTemplating
{
public class Tokeniser
{
string content;
int position = 0;
string value;
State nextState = State.Content;
Location nextStateLocation;
Location nextStateTagStartLocation;
public Tokeniser (string fileName, string content)
{
State = State.Content;
this.content = content;
this.Location = this.nextStateLocation = this.nextStateTagStartLocation = new Location (fileName, 1, 1);
}
public bool Advance ()
{
value = null;
State = nextState;
Location = nextStateLocation;
TagStartLocation = nextStateTagStartLocation;
if (nextState == State.EOF)
return false;
nextState = GetNextStateAndCurrentValue ();
return true;
}
State GetNextStateAndCurrentValue ()
{
switch (State) {
case State.Block:
case State.Expression:
case State.Helper:
return GetBlockEnd ();
case State.Directive:
return NextStateInDirective ();
case State.Content:
return NextStateInContent ();
case State.DirectiveName:
return GetDirectiveName ();
case State.DirectiveValue:
return GetDirectiveValue ();
default:
throw new InvalidOperationException ("Unexpected state '" + State.ToString () + "'");
}
}
State GetBlockEnd ()
{
int start = position;
for (; position < content.Length; position++) {
char c = content[position];
nextStateTagStartLocation = nextStateLocation;
nextStateLocation = nextStateLocation.AddCol ();
if (c == '\r') {
if (position + 1 < content.Length && content[position + 1] == '\n')
position++;
nextStateLocation = nextStateLocation.AddLine();
} else if (c == '\n') {
nextStateLocation = nextStateLocation.AddLine();
} else if (c =='>' && content[position-1] == '#' && content[position-2] != '\\') {
value = content.Substring (start, position - start - 1);
position++;
TagEndLocation = nextStateLocation;
//skip newlines directly after blocks, unless they're expressions
if (State != State.Expression && (position += IsNewLine()) > 0) {
nextStateLocation = nextStateLocation.AddLine ();
}
return State.Content;
}
}
throw new ParserException ("Unexpected end of file.", nextStateLocation);
}
State GetDirectiveName ()
{
int start = position;
for (; position < content.Length; position++) {
char c = content[position];
if (!Char.IsLetterOrDigit (c)) {
value = content.Substring (start, position - start);
return State.Directive;
} else {
nextStateLocation = nextStateLocation.AddCol ();
}
}
throw new ParserException ("Unexpected end of file.", nextStateLocation);
}
State GetDirectiveValue ()
{
int start = position;
int delimiter = '\0';
for (; position < content.Length; position++) {
char c = content[position];
nextStateLocation = nextStateLocation.AddCol ();
if (c == '\r') {
if (position + 1 < content.Length && content[position + 1] == '\n')
position++;
nextStateLocation = nextStateLocation.AddLine();
} else if (c == '\n')
nextStateLocation = nextStateLocation.AddLine();
if (delimiter == '\0') {
if (c == '\'' || c == '"') {
start = position;
delimiter = c;
} else if (!Char.IsWhiteSpace (c)) {
throw new ParserException ("Unexpected character '" + c + "'. Expecting attribute value.", nextStateLocation);
}
continue;
}
if (c == delimiter) {
value = content.Substring (start + 1, position - start - 1);
position++;
return State.Directive;
}
}
throw new ParserException ("Unexpected end of file.", nextStateLocation);;
}
State NextStateInContent ()
{
int start = position;
for (; position < content.Length; position++) {
char c = content[position];
nextStateTagStartLocation = nextStateLocation;
nextStateLocation = nextStateLocation.AddCol ();
if (c == '\r') {
if (position + 1 < content.Length && content[position + 1] == '\n')
position++;
nextStateLocation = nextStateLocation.AddLine();
} else if (c == '\n') {
nextStateLocation = nextStateLocation.AddLine();
} else if (c =='<' && position + 2 < content.Length && content[position+1] == '#') {
TagEndLocation = nextStateLocation;
char type = content[position+2];
if (type == '@') {
nextStateLocation = nextStateLocation.AddCols (2);
value = content.Substring (start, position - start);
position += 3;
return State.Directive;
} else if (type == '=') {
nextStateLocation = nextStateLocation.AddCols (2);
value = content.Substring (start, position - start);
position += 3;
return State.Expression;
} else if (type == '+') {
nextStateLocation = nextStateLocation.AddCols (2);
value = content.Substring (start, position - start);
position += 3;
return State.Helper;
} else {
value = content.Substring (start, position - start);
nextStateLocation = nextStateLocation.AddCol ();
position += 2;
return State.Block;
}
}
}
//EOF is only valid when we're in content
value = content.Substring (start);
return State.EOF;
}
int IsNewLine() {
int found = 0;
if (position < content.Length && content[position] == '\r') {
found++;
}
if (position+found < content.Length && content[position+found] == '\n') {
found++;
}
return found;
}
State NextStateInDirective () {
for (; position < content.Length; position++) {
char c = content[position];
if (c == '\r') {
if (position + 1 < content.Length && content[position + 1] == '\n')
position++;
nextStateLocation = nextStateLocation.AddLine();
} else if (c == '\n') {
nextStateLocation = nextStateLocation.AddLine();
} else if (Char.IsLetter (c)) {
return State.DirectiveName;
} else if (c == '=') {
nextStateLocation = nextStateLocation.AddCol ();
position++;
return State.DirectiveValue;
} else if (c == '#' && position + 1 < content.Length && content[position+1] == '>') {
position+=2;
TagEndLocation = nextStateLocation.AddCols (2);
nextStateLocation = nextStateLocation.AddCols (3);
//skip newlines directly after directives
if ((position += IsNewLine()) > 0) {
nextStateLocation = nextStateLocation.AddLine();
}
return State.Content;
} else if (!Char.IsWhiteSpace (c)) {
throw new ParserException ("Directive ended unexpectedly with character '" + c + "'", nextStateLocation);
} else {
nextStateLocation = nextStateLocation.AddCol ();
}
}
throw new ParserException ("Unexpected end of file.", nextStateLocation);
}
public State State {
get; private set;
}
public int Position {
get { return position; }
}
public string Content {
get { return content; }
}
public string Value {
get { return value; }
}
public Location Location { get; private set; }
public Location TagStartLocation { get; private set; }
public Location TagEndLocation { get; private set; }
}
public enum State
{
Content = 0,
Directive,
Expression,
Block,
Helper,
DirectiveName,
DirectiveValue,
Name,
EOF
}
public class ParserException : Exception
{
public ParserException (string message, Location location) : base (message)
{
Location = location;
}
public Location Location { get; private set; }
}
}

View file

@ -0,0 +1,19 @@
TextTemplating
==============
This is the TextTemplating tool inluded in MonoDevelop.
The original location of these files is
https://github.com/mono/monodevelop/tree/master/main/src/addins/TextTemplating
Building on Windows
-------------------
Run build.cmd or open TextTemplating.sln in visual studio 2010
Dotnet framework 4 must be installed.
License
-------
Licensed under the MIT/X11 license: http://www.opensource.org/licenses/mit-license.php

View file

@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.TextTemplating", "Mono.TextTemplating\Mono.TextTemplating.csproj", "{A2364D6A-00EF-417C-80A6-815726C70032}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextTransform", "TextTransform\TextTransform.csproj", "{D1D35409-C814-47F6-B038-B9B5BF0FE490}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Release|Any CPU = Release|Any CPU
Debug|Any CPU = Debug|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A2364D6A-00EF-417C-80A6-815726C70032}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2364D6A-00EF-417C-80A6-815726C70032}.Release|Any CPU.Build.0 = Release|Any CPU
{A2364D6A-00EF-417C-80A6-815726C70032}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A2364D6A-00EF-417C-80A6-815726C70032}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1D35409-C814-47F6-B038-B9B5BF0FE490}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1D35409-C814-47F6-B038-B9B5BF0FE490}.Release|Any CPU.Build.0 = Release|Any CPU
{D1D35409-C814-47F6-B038-B9B5BF0FE490}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1D35409-C814-47F6-B038-B9B5BF0FE490}.Debug|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Some files were not shown because too many files have changed in this diff Show more