private void listView_SelectedIndexChanged(object sender, EventArgs e) { if (listView.SelectedIndices.Count > 0) { int idx = listView.SelectedIndices[0]; Setting item = Settings.Datas[idx]; SubWindow.SetSettingData(item); textName.Text = item.Name; textTitle.Text = item.Title; numericOffsetX.Value = item.OffsetX; numericOffsetY.Value = item.OffsetY; numericWidth.Value = item.Width; numericHeight.Value = item.Height; checkDrawCursor.Checked = item.DrawCursor; numericInterval.Value = item.Interval; checkShowFPS.Checked = item.ShowFPS; } }
private void Save() { if (textName.Text.Length > 0 && textTitle.Text.Length > 0) { int idx = Settings.Datas.FindIndex((o) => { return(o.Name.Equals(textName.Text)); }); Setting item; if (idx > -1) { item = Settings.Datas[idx]; item.Name = textName.Text; item.Title = textTitle.Text; item.OffsetX = (int)numericOffsetX.Value; item.OffsetY = (int)numericOffsetY.Value; item.Width = (int)numericWidth.Value; item.Height = (int)numericHeight.Value; item.DrawCursor = checkDrawCursor.Checked; item.Interval = (int)numericInterval.Value; item.ShowFPS = checkShowFPS.Checked; } else { item = new Setting(); item.Name = textName.Text; item.Title = textTitle.Text; item.OffsetX = (int)numericOffsetX.Value; item.OffsetY = (int)numericOffsetY.Value; item.Width = (int)numericWidth.Value; item.Height = (int)numericHeight.Value; item.DrawCursor = checkDrawCursor.Checked; item.Interval = (int)numericInterval.Value; item.ShowFPS = checkShowFPS.Checked; Settings.Datas.Add(item); } SaveSettings(); RenderListView(); SubWindow.SetSettingData(item); } }