示例#1
0
        public static void Add(SIEEFactory f)
        {
            string key = f.CreateSettings().GetType().Name;

            if (!bySettingsType.ContainsKey(key))
            {
                bySettingsType.Add(key, f);
                key = f.CreateSettings().GetType().ToString();
                byTypeName.Add(key, f);
            }
        }
示例#2
0
        /// Various functions in the SIEE_Adapter need to access the true settings, i.e. the
        /// embedded settings. If there is no embedded settings yet, it will be recreated from
        /// the serialized version. If even that does not exist a brand new object is created
        /// from the factory.
        public SIEESettings GetEmbeddedSettings()
        {
            if (sieeSettings != null)
            {
                return(sieeSettings);
            }

            if (!string.IsNullOrEmpty(SerializedSettings))
            {
                try
                {
                    //throw new Exception("Test dummy exception");
                    string xmlString = (string)SIEESerializer.StringToObject(SerializedSettings);
                    sieeSettings = (SIEESettings)Serializer.DeserializeFromXmlString(xmlString, factory.CreateSettings().GetType(), System.Text.Encoding.Unicode);
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show(
                        "Error loading export destination. \n" +
                        "Settings for export extension is lost.\n" +
                        "You need to reconfigure the export extension\n\n" +
                        $"Extension type = {SettingsTypename}\n" +
                        e.ToString(),
                        "Load profile",
                        System.Windows.Forms.MessageBoxButtons.OK,
                        System.Windows.Forms.MessageBoxIcon.Error
                        );
                    sieeSettings = factory.CreateSettings();
                }
            }
            else
            {
                sieeSettings = factory.CreateSettings();
            }
            return(sieeSettings);
        }
示例#3
0
        private void loadExportExtention(SIEEFactory factory)
        {
            try
            {
                control     = new SIEEControl(factory);
                settings    = (SIEESettings)factory.CreateSettings();
                export      = (SIEEExport)factory.CreateExport();
                description = (SIEEDescription)factory.CreateDescription();
            }
            catch (Exception ex) { MessageBox.Show("Factory error.\n" + ex.Message); }

            if (chbox_reloadConfiguration.Checked && Properties.Settings.Default.SavedConfigurationType == description.TypeName)
            {
                try
                {
                    settings = (SIEESettings)SIEESerializer.StringToObject(Properties.Settings.Default.SavedConfiguration);
                }
                catch (Exception e)
                {
                    MessageBox.Show("Loading saved configuration failed. Rason:\n" + e.Message);
                }
            }
            btn_configure.Enabled = false;
            btn_capture.Enabled   = false;
            btn_export.Enabled    = false;

            try { SIEESerializer.StringToObject(SIEESerializer.ObjectToString(settings)); }
            catch (Exception ex)
            {
                MessageBox.Show("Serialization for settings object failed:\n" + ex.Message);
                cbox_extensionSelector.SelectedText = Properties.Settings.Default.CurrentExtension;
                return;
            }
            pict_Icon.Image       = description.Image;
            btn_configure.Enabled = true;
            Properties.Settings.Default.CurrentExtension = cbox_extensionSelector.Text;
            lbl_status.Text = "Extension selected";
        }
示例#4
0
 public void SetFactory(SIEEFactory f)
 {
     factory = f;
     this.SettingsTypename = factory.CreateSettings().GetType().ToString();
 }