/// <summary> /// Update the bounding box which contains all device's mirroring zones /// </summary> public void UpdateBoundingBox() { int minTop = int.MaxValue, maxBot = int.MinValue, minLeft = int.MaxValue, maxRight = int.MinValue; foreach(int id in Settings.Keys) { DeviceSettings settings = Settings[id]; int left = settings.x; int right = settings.width + left; int top = settings.y; int bot = top + settings.height; minTop = minTop < top ? minTop : top; maxBot = maxBot > bot ? maxBot : bot; minLeft = minLeft < left ? minLeft : left; maxRight = maxRight > right ? maxRight : right; } boundX = minLeft; boundY = minTop; boundWidth = maxRight - minLeft; boundHeight = maxBot - minTop; SettingsDelta Delta = new SettingsDelta(); Delta.changes[SettingValue.BOUNDX] = boundX; Delta.changes[SettingValue.BOUNDY] = boundY; Delta.changes[SettingValue.BOUNDWIDTH] = boundWidth; Delta.changes[SettingValue.BOUNDHEIGHT] = boundHeight; Log("New bounding box calculated.\n" + Delta.ToString()); foreach(int id in Settings.Keys) { Settings[id].ApplyChanges(Delta); } }
public void ApplyChanges(SettingsDelta delta) { Log(delta.changes.Count + " settings updated.\t" + delta.ToString()); foreach(SettingValue variable in delta.changes.Keys) { switch(variable) { case SettingValue.BLUEBIAS: blueBias = (Int16)delta.changes[SettingValue.BLUEBIAS]; break; case SettingValue.BOUNDHEIGHT: boundHeight = (int)delta.changes[SettingValue.BOUNDHEIGHT]; break; case SettingValue.BOUNDWIDTH: boundWidth = (int)delta.changes[SettingValue.BOUNDWIDTH]; break; case SettingValue.BOUNDX: boundX = (int)delta.changes[SettingValue.BOUNDX]; break; case SettingValue.BOUNDY: boundY = (int)delta.changes[SettingValue.BOUNDY]; break; case SettingValue.CAPTURETHROTTLE: captureThrottle = (int)delta.changes[SettingValue.CAPTURETHROTTLE]; break; case SettingValue.GREENBIAS: greenBias = (Int16)delta.changes[SettingValue.GREENBIAS]; break; case SettingValue.HEIGHT: height = (int)delta.changes[SettingValue.HEIGHT]; break; case SettingValue.MAXBRIGHTNESS: maxBrightness = (double)delta.changes[SettingValue.MAXBRIGHTNESS]; break; case SettingValue.NEWCOLORWEIGHT: newColorWeight = (double)delta.changes[SettingValue.NEWCOLORWEIGHT]; break; case SettingValue.REDBIAS: redBias = (Int16)delta.changes[SettingValue.REDBIAS]; break; case SettingValue.STEPSLEEP: stepSleep = (int)delta.changes[SettingValue.STEPSLEEP]; break; case SettingValue.WEIGHTINGENABLED: weightingEnabled = (bool)delta.changes[SettingValue.WEIGHTINGENABLED]; break; case SettingValue.WIDTH: width = (int)delta.changes[SettingValue.WIDTH]; break; case SettingValue.X: x = (int)delta.changes[SettingValue.X]; break; case SettingValue.Y: y = (int)delta.changes[SettingValue.Y]; break; default: Log("Unknown SettingValue " + variable); break; } } Save(); Notify(); }