Esempio n. 1
0
        /// <summary> Import toolbar button </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="e">Event Args</param>
        /// <remarks>Import resource info from a text file </remarks>
        private void btnImport_Click(object sender, EventArgs e)
        {
            // Init dialog
            var dialog = new OpenFileDialog
            {
                CheckFileExists = true,
                CheckPathExists = true,
                Filter          = Properties.Resources.Filter,
                FilterIndex     = 1,
                Multiselect     = false
            };

            // Show the dialog and evaluate action
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                // Open the file and assign to resource info which is bound to the grid
                try
                {
                    _resourceInfo = _generation.GetResourceInfo(dialog.FileName);
                    // Assign binding to datasource (two binding)
                    grdResourceInfo.DataSource = _resourceInfo;
                }
                catch (Exception exception)
                {
                    DisplayMessage(exception.Message, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Run headless or via generation form?
            if (args.Length == 0)
            {
                Application.Run(new Generation());
            }
            else
            {
                var generation = new ProcessGeneration();

                // Get rid of quotes
                for (var arg = 0; arg < args.Length; arg++)
                {
                    args[arg] = args[arg].Replace("\"", "");
                }

                // Get resource info and validate
                var resourceInfo = generation.GetResourceInfo(@args[0]);
                if (!generation.ValidResourceInfo(resourceInfo))
                {
                    throw new Exception(Properties.Resources.ErrorResourceFile);
                }

                // Get settings and validate
                var settings = generation.BuildSettings(generation.GetSettings(@args[1]));
                if (!generation.ValidSettings(settings))
                {
                    throw new Exception(Properties.Resources.ErrorSettingsFile);
                }

                // Add resource info and settings to a dictionary to be passed to processing class
                var dictionary = new Dictionary <string, object>
                {
                    { ProcessGeneration.ResourceInfoKey, resourceInfo },
                    { ProcessGeneration.SettingsKey, settings }
                };

                // Start process
                generation.Process(dictionary);
            }
        }