public OSDForm() { InitializeComponent(); this.localizeComponent(); mGroupListView.Columns.Add("Color", 50); mGroupListView.Columns.Add("Name", 130); mGroupListView.SelectedIndexChanged += onGroupListViewIndexChanged; mGroupListView.MouseDoubleClick += onGroupListViewMouseDoubleClick; mGroupEditTextBox.Leave += onGroupEditTextBoxLeave; mGroupEditTextBox.Hide(); mItemListView.Columns.Add("Color", 50); mItemListView.Columns.Add("Item", 280); mDigitNumericUpDown.ValueChanged += onDigitNumericUpDownValueChanged; this.enableItemConrol(false); var hardwareManager = HardwareManager.getInstance(); var osdSensorList = hardwareManager.OSDSensorList; for (int i = 0; i < osdSensorList.Count; i++) { var sensor = osdSensorList[i]; var item = new OSDItem(); item.UnitType = sensor.UnitType; item.ID = sensor.ID; mComboBoxItemList.Add(item); mItemComboBox.Items.Add(sensor.Prefix + sensor.Name); } mItemComboBox.SelectedIndex = 0; mEnableCheckBox.Checked = OSDManager.getInstance().IsEnable; mSystemTimeCheckBox.Checked = OSDManager.getInstance().IsTime; mGroupList = OSDManager.getInstance().getCloneGroupList(); for (int i = 0; i < mGroupList.Count; i++) { var group = mGroupList[i]; var item = new ListViewItem(); if (group.IsColor == false) { item.Text = "Default"; } else { item.Text = ""; item.BackColor = group.Color; } item.SubItems.Add(group.Name); item.UseItemStyleForSubItems = false; mGroupListView.Items.Add(item); } }
public OSDItem clone() { var item = new OSDItem(); item.UnitType = this.UnitType; item.ID = this.ID; item.IsColor = this.IsColor; item.Color = Color.FromArgb(this.Color.R, this.Color.G, this.Color.B); return(item); }
public OSDForm() { InitializeComponent(); this.localizeComponent(); mGroupListView.Columns.Add("Color", 50); mGroupListView.Columns.Add("Name", 130); mGroupListView.SelectedIndexChanged += onGroupListViewIndexChanged; mGroupListView.MouseDoubleClick += onGroupListViewMouseDoubleClick; mGroupEditTextBox.Leave += onGroupEditTextBoxLeave; mGroupEditTextBox.Hide(); mItemListView.Columns.Add("Color", 50); mItemListView.Columns.Add("Item", 280); mDigitNumericUpDown.ValueChanged += onDigitNumericUpDownValueChanged; this.enableItemConrol(false); var hardwareManager = HardwareManager.getInstance(); var controlManager = ControlManager.getInstance(); // Sensor for (int i = 0; i < hardwareManager.getSensorCount(); i++) { var sensor = hardwareManager.getSensor(i); var item = new OSDItem(); item.ItemType = OSDItemType.Sensor; item.UnitType = OSDUnitType.Temperature; item.Index = i; mComboBoxItemList.Add(item); mItemComboBox.Items.Add("[" + StringLib.Temperature + "] " + controlManager.getName(0, i, false)); } // Fan for (int i = 0; i < hardwareManager.getFanCount(); i++) { var fan = hardwareManager.getFan(i); var item = new OSDItem(); item.ItemType = OSDItemType.Fan; item.UnitType = OSDUnitType.RPM; item.Index = i; mComboBoxItemList.Add(item); mItemComboBox.Items.Add("[" + StringLib.Fan_speed + "] " + controlManager.getName(1, i, false)); } // Control for (int i = 0; i < hardwareManager.getControlCount(); i++) { var control = hardwareManager.getControl(i); var item = new OSDItem(); item.ItemType = OSDItemType.Control; item.UnitType = OSDUnitType.Percent; item.Index = i; mComboBoxItemList.Add(item); mItemComboBox.Items.Add("[" + StringLib.Fan_control + "] " + controlManager.getName(2, i, false)); } // Predefined // Framerate var osdItem = new OSDItem(); osdItem.ItemType = OSDItemType.Predefined; osdItem.UnitType = OSDUnitType.FPS; mComboBoxItemList.Add(osdItem); mItemComboBox.Items.Add("[" + StringLib.ETC + "] Framerate"); // Blank osdItem = new OSDItem(); osdItem.ItemType = OSDItemType.Predefined; osdItem.UnitType = OSDUnitType.Blank; mComboBoxItemList.Add(osdItem); mItemComboBox.Items.Add("[" + StringLib.ETC + "] Blank"); // osd sensor for (int i = 0; i < hardwareManager.getOSDSensorCount(); i++) { var osdSensor = hardwareManager.getOSDSensor(i); var item = new OSDItem(); item.ItemType = OSDItemType.Predefined; item.UnitType = osdSensor.UnitType; item.Index = i; mComboBoxItemList.Add(item); mItemComboBox.Items.Add(osdSensor.Name); } mItemComboBox.SelectedIndex = 0; mEnableCheckBox.Checked = OSDManager.getInstance().IsEnable; mSystemTimeCheckBox.Checked = OSDManager.getInstance().IsTime; mGroupList = OSDManager.getInstance().getCloneGroupList(); for (int i = 0; i < mGroupList.Count; i++) { var group = mGroupList[i]; var item = new ListViewItem(); if (group.IsColor == false) { item.Text = "Default"; } else { item.Text = ""; item.BackColor = group.Color; } item.SubItems.Add(group.Name); item.UseItemStyleForSubItems = false; mGroupListView.Items.Add(item); } }
public void read() { Monitor.Enter(mLock); String jsonString; try { jsonString = File.ReadAllText(mOSDFileName); } catch { this.clear(); Monitor.Exit(mLock); this.write(); return; } try { var rootObject = JObject.Parse(jsonString); mIsEnable = (rootObject.ContainsKey("enable") == true) ? rootObject.Value <bool>("enable") : false; mIsTime = (rootObject.ContainsKey("time") == true) ? rootObject.Value <bool>("time") : false; if (rootObject.ContainsKey("group") == true) { var groupList = rootObject.Value <JArray>("group"); for (int i = 0; i < groupList.Count; i++) { var groupObject = (JObject)groupList[i]; string name = (groupObject.ContainsKey("name") == false) ? "" : groupObject.Value <string>("name"); bool isColor = (groupObject.ContainsKey("isColor") == false) ? false : groupObject.Value <bool>("isColor"); byte r = (groupObject.ContainsKey("r") == false) ? (byte)0xFF : groupObject.Value <byte>("r"); byte g = (groupObject.ContainsKey("g") == false) ? (byte)0xFF : groupObject.Value <byte>("g"); byte b = (groupObject.ContainsKey("b") == false) ? (byte)0xFF : groupObject.Value <byte>("b"); int digit = (groupObject.ContainsKey("digit") == false) ? 5 : groupObject.Value <int>("digit"); var group = new OSDGroup(); group.Name = name; group.IsColor = isColor; group.Color = Color.FromArgb(r, g, b); group.Digit = digit; if (groupObject.ContainsKey("item") == true) { var itemList = groupObject.Value <JArray>("item"); for (int j = 0; j < itemList.Count; j++) { var itemObject = (JObject)itemList[j]; var itemType = (itemObject.ContainsKey("itemType") == false) ? (int)OSDItemType.Unknown : itemObject.Value <int>("itemType"); var unitType = (itemObject.ContainsKey("unitType") == false) ? (int)OSDUnitType.Unknown : itemObject.Value <int>("unitType"); int index = (itemObject.ContainsKey("index") == false) ? 0 : itemObject.Value <int>("index"); isColor = (itemObject.ContainsKey("isColor") == false) ? false : itemObject.Value <bool>("isColor"); r = (itemObject.ContainsKey("r") == false) ? (byte)0xFF : itemObject.Value <byte>("r"); g = (itemObject.ContainsKey("g") == false) ? (byte)0xFF : itemObject.Value <byte>("g"); b = (itemObject.ContainsKey("b") == false) ? (byte)0xFF : itemObject.Value <byte>("b"); if (itemType >= (int)OSDItemType.Unknown || unitType >= (int)OSDUnitType.Unknown) { continue; } var item = new OSDItem(); item.ItemType = (OSDItemType)itemType; item.UnitType = (OSDUnitType)unitType; item.Index = index; item.IsColor = isColor; item.Color = Color.FromArgb(r, g, b); group.ItemList.Add(item); } } mGroupList.Add(group); } } } catch { this.clear(); Monitor.Exit(mLock); return; } Monitor.Exit(mLock); }