Пример #1
0
        private void btnLoadEnumOptions_Click(object sender, EventArgs e)
        {
            //Prepare OpenFileDialog parameters
            openFileDialog1.InitialDirectory = Properties.Settings.Default.MarlinDirectory;
            openFileDialog1.Filter           = "h files (*.h)|*.h";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;
            openFileDialog1.FileName         = "";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                //Get the path of specified file
                string filePath = openFileDialog1.FileName;

                //Allitems will have all #defines in choosen .h file
                cMarlinSettings AllItems = new cMarlinSettings();

                //LoadedEnumOptions will have only the integer #defines of AllItems
                //cMarlinSettings EnumOptions = new cMarlinSettings();
                LoadedEnumOptions.Clear();

                //Load #defines from .h and store in AllItems
                MarlingRWConfig.ReadConfig(AllItems, filePath);

                // Filter the integer #defines and store them in LoadedEnumOptions
                foreach (var key in AllItems.Keys)
                {
                    if (AllItems[key] is Int32)
                    {
                        LoadedEnumOptions.Add(key, (Int32)AllItems[key]);
                    }
                }
                FillListBoxLoadedOptions();
            }
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            MarlingRWConfig.ReadConfig(MarlinSettings, Properties.Settings.Default.MarlinDirectory + "\\Marlin\\Configuration.h");

            foreach (var key in MarlinSettings.Keys)
            {
                listBox1.Items.Add(key + ' ' + MarlinSettings[key]);
            }

            /*
             * MarlinSettings.Add("Prop1","Value1");
             * MarlinSettings.Add("Prop2", 38);
             *
             * cMarlinSettings Group1 = new cMarlinSettings();
             * Group1.Title = "Group1";
             * Group1.Add("Prop1", true);
             *
             *  cMarlinSettings Group11 = new cMarlinSettings();
             *  Group11.Title = "Group11";
             *  Group11.Add("Prop1", "Value1");
             *  Group11.Add("Prop2", 128);
             *  Group1.Add("Group11", Group11);
             *
             * Group1.Add("Prop2", 0.381);
             * Group1.Add("Prop3", 12);
             * MarlinSettings.Add("Group1", Group1);
             *
             * cMarlinSettings Group2 = new cMarlinSettings();
             * Group2.Title = "Group2";
             * Group2.Add("Prop1",false);
             * Group2.Add("Prop2", 0.167);
             * MarlinSettings.Add("Group2", Group1);
             *
             * MarlinSettings.Add("Prop3", "Value3");*/
            //((IDictionary<String, Object>)MarlinConfig).Add("Prop1", a);
        }