예제 #1
0
        private void ShowProfile(int index)
        {
            var profile = ccmsg.GetProfile(index);

            for (int i = 0; i < GlobalSetting.KeyMaxNumber; i++)
            {
                modeContainers[i].Clean();
                modeContainers[i].SetInfoText.Text = profile.jSONModes[i].Set;
                modeContainers[i].ModeComboBox.Items.Clear();
                foreach (var mode in ModeFactory.Modes)
                {
                    modeContainers[i].ModeComboBox.Items.Add(mode.OptionInfo);
                    if (mode.Name == profile.jSONModes[i].Name)
                    {
                        modeContainers[i].ModeComboBox.SelectedIndex = modeContainers[i].ModeComboBox.Items.Count - 1;
                    }
                }

                int lambdaIndex = index, lambdaI = i;

                modeContainers[i].SetButton.Click += (object sender, EventArgs e) =>
                {
                    string newSet = ModeFactory.Get(profile.jSONModes[lambdaI].Name).SettingForm.GetSet();
                    if (newSet != "cancel")
                    {
                        if (!ccmsg.ChangeProfileMode(lambdaIndex, lambdaI, profile.jSONModes[lambdaI].Name, newSet))
                        {
                            MessageBox.Show("設定檔變更失敗");
                        }
                        else
                        {
                            modeContainers[lambdaI].SetInfoText.Text = newSet;
                        }
                    }
                };

                modeContainers[i].ModeComboBox.TextChanged += (object sender, EventArgs e) =>
                {
                    string newSet = ModeFactory.GetByOptionInfo(modeContainers[lambdaI].ModeComboBox.Text).SettingForm.GetSet();
                    if (newSet != "cancel")
                    {
                        if (!ccmsg.ChangeProfileMode(lambdaIndex, lambdaI, ModeFactory.GetByOptionInfo(modeContainers[lambdaI].ModeComboBox.Text).Name, newSet))
                        {
                            MessageBox.Show("設定檔變更失敗");
                            ShowProfile(lambdaIndex);
                        }
                        else
                        {
                            modeContainers[lambdaI].SetInfoText.Text = newSet;
                        }
                    }
                    else
                    {
                        ShowProfile(lambdaIndex);
                    }
                };
            }
        }
예제 #2
0
 //Make handlers for scheduler from profiles
 private Handler.IHandler[] MakeHandlers(JSONProfile profile)
 {
     Handler.IHandler[] handlers = new Handler.IHandler[GlobalSetting.KeyMaxNumber];
     for (int i = 0; i < handlers.Length; i++)
     {
         handlers[i] = ModeFactory.Get(profile.jSONModes[i].Name).CreateHanlder(profile.jSONModes[i].Set);
     }
     return(handlers);
 }