Ejemplo n.º 1
0
        static void Main(string [] args)
        {
            UserPreferences oPreferences = Program.ReadUserPreferences();

            // License agreement.
            if (Convert.ToBoolean(oPreferences.ShowLicense))
            {
                using (System.IO.Stream oStream = typeof(Program).Assembly.GetManifestResourceStream("Sharepoint.DBExporter._License.txt"))
                {
                    System.IO.StreamReader oReader = new System.IO.StreamReader(oStream);

                    string sLicense = oReader.ReadToEnd();

                    System.Windows.Forms.DialogResult nResult = System.Windows.Forms.MessageBox.Show(sLicense + "\r\n\r\nAccept?", "License", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Information);
                    // if do not agree with license terms, exit.
                    if (nResult == System.Windows.Forms.DialogResult.No)
                    {
                        return;
                    }
                }

                //if flag was not defined, we show it once then we don't bother the user anymore.
                if (oPreferences.ShowLicense == -1)
                {
                    oPreferences.ShowLicense = 0;
                    Program.WriteUserPreferences(oPreferences);
                }
            }

            ExecutionContext oContext = Program.GetContextFromCommandLine(args);

            if (oContext == null)
            {
                oContext = Program.GetContextFromUser();
            }

            if (oContext != null && oContext != ExecutionContext.None)
            {
                oContext.Preferences = oPreferences;

                using (UI.ExplorerForm oMainForm = new UI.ExplorerForm())
                {
                    oMainForm.ExecutionContext = oContext;

                    Application.Run(oMainForm);

                    Program.WriteUserPreferences(oContext.Preferences);
                }
            }
        }
Ejemplo n.º 2
0
        private static void WriteUserPreferences(UserPreferences preferences)
        {
            System.Xml.Serialization.XmlSerializer oSerializer = new System.Xml.Serialization.XmlSerializer(typeof(UserPreferences));
            string sPath = System.IO.Path.ChangeExtension(System.Reflection.Assembly.GetExecutingAssembly().Location, "pref.xml");

            System.Xml.XmlTextWriter oWriter = new System.Xml.XmlTextWriter(sPath, System.Text.Encoding.UTF8);
            oWriter.Formatting = System.Xml.Formatting.Indented;
            try
            {
                oSerializer.Serialize(oWriter, preferences);
            }
            finally
            {
                oWriter.Close();
            }
        }
Ejemplo n.º 3
0
		private static UserPreferences ReadUserPreferences()
		{
			string sPath = System.IO.Path.ChangeExtension(System.Reflection.Assembly.GetExecutingAssembly().Location, "pref.xml");
			UserPreferences oReturn = null;

			if (System.IO.File.Exists(sPath))
			{
				System.Xml.Serialization.XmlSerializer oSerializer = new System.Xml.Serialization.XmlSerializer(typeof(UserPreferences));
				System.Xml.XmlTextReader oReader = new System.Xml.XmlTextReader(sPath);

				try
				{
					oReturn = (UserPreferences) oSerializer.Deserialize(oReader);
				}
				catch (Exception)
				{
					oReturn = new UserPreferences();
				}
				finally
				{
					oReader.Close();
				}
			}

			if (oReturn == null)
				oReturn = new UserPreferences();

			return (oReturn);
		}
Ejemplo n.º 4
0
		private static void WriteUserPreferences(UserPreferences preferences)
		{
			System.Xml.Serialization.XmlSerializer oSerializer = new System.Xml.Serialization.XmlSerializer(typeof(UserPreferences));
			string sPath = System.IO.Path.ChangeExtension(System.Reflection.Assembly.GetExecutingAssembly().Location, "pref.xml");

			System.Xml.XmlTextWriter oWriter = new System.Xml.XmlTextWriter(sPath, System.Text.Encoding.UTF8);
			oWriter.Formatting = System.Xml.Formatting.Indented;
			try
			{
				oSerializer.Serialize(oWriter, preferences);
			}
			finally
			{
				oWriter.Close();
			}
		}