Пример #1
0
        public MainForm()
        {
            mfm = new MainFormModel();
            InitializeComponent();
            foreach (var i in mfm.templates)
            {
                templateList.Items.Add(i.TemplateName);
            }

            #region Load Default Model
            templateName.Text          = DefaultTemplate.TemplateName;
            usingImage.Checked         = DefaultTemplate.UsingImage;
            useDeviceName.Checked      = DefaultTemplate.UseDeviceName;
            loop.Checked               = DefaultTemplate.LoopAnimation;
            assetLocation.Text         = DefaultTemplate.AssetLocation;
            defaultName.Text           = DefaultTemplate.DefaultDeviceName;
            buttonText.Text            = DefaultTemplate.ButtonText;
            windowBackground.BackColor = mfm.FromHex(DefaultTemplate.WindowBackground);
            windowForeground.BackColor = mfm.FromHex(DefaultTemplate.WindowForeground);
            buttonBackground.BackColor = mfm.FromHex(DefaultTemplate.ButtonBackground);
            buttonForeground.BackColor = mfm.FromHex(DefaultTemplate.ButtonForeground);
            tint.BackColor             = mfm.FromHex(DefaultTemplate.Tint);
            #endregion

            foreach (var i in mfm.devices.Devices)
            {
                deviceList.Items.Add(i.DeviceName);
            }
        }
Пример #2
0
        private void add_Click(object sender, EventArgs e)
        {
            try
            {
                string path = MainFormModel.CombinePathsStatic(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "\\AirPodsUI");
                string file = MainFormModel.CombinePathsStatic(path, "PairedDevices.json");

                string contents = "";

                using (StreamReader sr = new StreamReader(file))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        contents += line;
                    }
                }

                PairedDevices pdevices = new PairedDevices();
                pdevices = PairedDevices.FromJson(contents);

                pdevices.Devices.Add(new Device()
                {
                    DeviceAddress    = devices[usbDevices.SelectedIndex].DeviceID,
                    DeviceName       = name.Text,
                    DeviceType       = "USB",
                    TemplateLocation = ""
                });

                string result = Serialize.ToJson(pdevices);

                using (StreamWriter sw = new StreamWriter(file))
                {
                    sw.WriteLine(result);
                }
                this.Close();
            }
            catch (Exception ee)
            {
                MessageBox.Show("Unable to add to list", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }