Example #1
0
        private void HandleLaunchSettings()
        {
            string[] configNames = new string[] { ConfigType.DefaultSourcePort.ToString("g"), ConfigType.DefaultIWad.ToString("g"), ConfigType.DefaultSkill.ToString("g") };
            string[] strArray    = new string[] { (this.cmbSourcePorts.SelectedItem == null) ? null : ((ISourcePortDataSource)this.cmbSourcePorts.SelectedItem).SourcePortID.ToString(), (this.cmbIwad.SelectedItem == null) ? null : ((IIWadDataSource)this.cmbIwad.SelectedItem).IWadID.ToString(), this.cmbSkill.SelectedItem?.ToString() };
            IEnumerable <IConfigurationDataSource> enumerable = from x in this.DataSourceAdapter.GetConfiguration()
                                                                where configNames.Contains <string>(x.Name)
                                                                select x;

            for (int i = 0; i < configNames.Length; i++)
            {
                string configName           = configNames[i];
                string configValue          = strArray[i];
                IConfigurationDataSource ds = (from x in enumerable
                                               where x.Name == configName
                                               select x).FirstOrDefault <IConfigurationDataSource>();
                if (configValue != null)
                {
                    if (ds == null)
                    {
                        ds = CreateConfig(configName, configValue);
                        this.DataSourceAdapter.InsertConfiguration(ds);
                    }
                    else
                    {
                        ds.Value = configValue;
                        this.DataSourceAdapter.UpdateConfiguration(ds);
                    }
                }
            }
        }
Example #2
0
        public void InsertConfiguration(IConfigurationDataSource ds)
        {
            List <DbParameter> list;

            string[] exclude = new string[] { "ConfigID" };
            string   sql     = this.InsertStatement("Configuration", ds, exclude, out list);

            this.DataAccess.ExecuteNonQuery(sql, list);
        }
Example #3
0
        public void UpdateConfiguration(IConfigurationDataSource ds)
        {
            string             sql        = "update Configuration set \r\n            Name = @Name, Value = @Value, AvailableValues = @AvailableValues\r\n            where ConfigID = @ConfigID";
            List <DbParameter> parameters = new List <DbParameter> {
                this.DataAccess.DbAdapter.CreateParameter("Name", (ds.Name == null) ? string.Empty : ds.Name),
                this.DataAccess.DbAdapter.CreateParameter("Value", (ds.Value == null) ? string.Empty : ds.Value),
                this.DataAccess.DbAdapter.CreateParameter("AvailableValues", (ds.AvailableValues == null) ? string.Empty : ds.AvailableValues),
                this.DataAccess.DbAdapter.CreateParameter("ConfigID", ds.ConfigID)
            };

            this.DataAccess.ExecuteNonQuery(sql, parameters);
        }
Example #4
0
        private AppVersion GetVersion()
        {
            IConfigurationDataSource source = (from x in this.m_adapter.GetConfiguration()
                                               where x.Name == "Version"
                                               select x).FirstOrDefault <IConfigurationDataSource>();

            if (source != null)
            {
                return((AppVersion)Convert.ToInt32(source.Value));
            }
            return(AppVersion.Unknown);
        }
Example #5
0
        public string GetConfigValue(ConfigType ct)
        {
            IConfigurationDataSource source = (from x in this.DataSourceAdapter.GetConfiguration()
                                               where x.Name == ct.ToString("g")
                                               select x).FirstOrDefault <IConfigurationDataSource>();

            if (source != null)
            {
                return(source.Value);
            }
            return(null);
        }
Example #6
0
        private void WriteVersion(AppVersion version)
        {
            IConfigurationDataSource ds = (from x in this.m_adapter.GetConfiguration()
                                           where x.Name == "Version"
                                           select x).FirstOrDefault <IConfigurationDataSource>();

            if (ds != null)
            {
                ds.Value = Convert.ToInt32(version).ToString();
                this.m_adapter.UpdateConfiguration(ds);
            }
            else
            {
                ConfigurationDataSource source2 = new ConfigurationDataSource {
                    Name          = "Version",
                    UserCanModify = false,
                    Value         = Convert.ToInt32(version).ToString()
                };
                this.m_adapter.InsertConfiguration(source2);
            }
        }
Example #7
0
 private string GetValue(IConfigurationDataSource ds, object value)
 {
     if (!string.IsNullOrEmpty(ds.AvailableValues))
     {
         ComboBox box = value as ComboBox;
         if ((box != null) && (box.SelectedItem != null))
         {
             Tuple <string, string> selectedItem = box.SelectedItem as Tuple <string, string>;
             if (selectedItem != null)
             {
                 return(selectedItem.Item2);
             }
         }
     }
     else
     {
         TextBox box2 = value as TextBox;
         if (box2 != null)
         {
             return(box2.Text);
         }
     }
     return(string.Empty);
 }
Example #8
0
 internal bool <PopulateConfiguration> b__5_0(IConfigurationDataSource item) =>
Example #9
0
        private void PopulateConfiguration()
        {
            TableLayoutPanel panel = new TableLayoutPanel {
                Dock = DockStyle.Top
            };

            panel.RowStyles.Add(new RowStyle(SizeType.Absolute, 8f));
            int num = 8;

            using (IEnumerator <IConfigurationDataSource> enumerator = (from item in this.DataSourceAdapter.GetConfiguration()
                                                                        where item.UserCanModify
                                                                        select item).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    IConfigurationDataSource ds = enumerator.Current;
                    GrowLabel control           = new GrowLabel {
                        Anchor = AnchorStyles.Left,
                        Text   = AddSpaceBetweenWords(ds.Name)
                    };
                    panel.RowStyles.Add(new RowStyle(SizeType.Absolute, (control.Height < 0x20) ? ((float)0x20) : ((float)control.Height)));
                    panel.Controls.Add(control, 0, panel.RowStyles.Count - 1);
                    if (!string.IsNullOrEmpty(ds.AvailableValues))
                    {
                        ComboBox box = new ComboBox {
                            Dock = DockStyle.Fill
                        };
                        char[]   separator = new char[] { ';' };
                        string[] strArray  = ds.AvailableValues.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                        List <Tuple <string, string> > list = new List <Tuple <string, string> >();
                        for (int i = 0; i < (strArray.Length - 1); i += 2)
                        {
                            list.Add(new Tuple <string, string>(strArray[i], strArray[i + 1]));
                        }
                        box.ValueMember    = "Item1";
                        box.DataSource     = list;
                        box.BindingContext = new BindingContext();
                        box.SelectedItem   = (from item in list
                                              where item.Item2 == ds.Value
                                              select item).FirstOrDefault <Tuple <string, string> >();
                        panel.Controls.Add(box, 1, panel.RowStyles.Count - 1);
                        this.m_configValues.Add(new Tuple <IConfigurationDataSource, object>(ds, box));
                    }
                    else
                    {
                        TextBox box2 = new TextBox {
                            Dock = DockStyle.Fill,
                            Text = ds.Value
                        };
                        this.m_configValues.Add(new Tuple <IConfigurationDataSource, object>(ds, box2));
                        if (ds.Name == "GameFileDirectory")
                        {
                            this.m_gameFileDirectory       = box2;
                            this.m_gameFileDirectory.Width = 170;
                            FlowLayoutPanel panel2 = new FlowLayoutPanel {
                                Dock     = DockStyle.Fill,
                                Controls = { this.m_gameFileDirectory }
                            };
                            Button button = new Button {
                                Text = "Browse..."
                            };
                            button.Click += new EventHandler(this.browseButton_Click);
                            panel2.Controls.Add(button);
                            panel.Controls.Add(panel2, 1, panel.RowStyles.Count - 1);
                        }
                        else
                        {
                            panel.Controls.Add(box2, 1, panel.RowStyles.Count - 1);
                        }
                    }
                    num += 0x20;
                }
            }
            panel.RowStyles.Add(new RowStyle(SizeType.Percent, 100f));
            panel.Height = num;
            this.tabControl.TabPages[0].Controls.Add(panel);
            base.Height = num + 110;
        }
Example #10
0
 public void UpdateConfiguration(IConfigurationDataSource ds)
 {
     throw new NotImplementedException();
 }