internal CalibrationUserControl(ClientTagVisualization parent, CalibrationData existingCalibration)
            : this(parent, false)
        {
            // Nice-To-Have: Indlæs eksisterende calibration her...
            this.MinWidth = 180;
            this.MinHeight = 300;
            LayoutControl(300, 180);

            if (existingCalibration != null)
            {
                AdjustWidth(existingCalibration.Width);
                AdjustHeight(existingCalibration.Height);
            }
        }
        private void LoadData()
        {
            if (!Settings.LoadCalibrations && !Settings.LoadAndSaveCalibrations) return;
            if (!File.Exists(DataPath)) return; // File does not exist
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(DataPath);
                XmlNode root = doc.DocumentElement;
                string versionNr = root.SelectSingleNode("/NAIFrameworkData/@version").Value;
                if (versionNr.Equals(ClientDataStorage.VersionNr))
                {

                    XmlNodeList clients = root.SelectNodes("/NAIFrameworkData/Clients/Client");
                    if (clients != null)
                    {
                        foreach (XmlNode client in clients)
                        {
                            // Client Identity
                            string tagType = client.SelectSingleNode("@TagType").Value;
                            string tagValue = client.SelectSingleNode("@TagValue").Value;
                            //ClientIdentity clientId = ClientHandler.Instance.GetClientIdentity(tagType, tagValue);
                            string key = string.Format("{0};{1}", tagType, tagValue);

                            // Calibration
                            string offsetInchesX = client.SelectSingleNode("Calibration/@CenterOffsetInchesX").Value;
                            string offsetInchesY = client.SelectSingleNode("Calibration/@CenterOffsetInchesY").Value;
                            string orientation = client.SelectSingleNode("Calibration/@Orientation").Value;
                            string screenWidth = client.SelectSingleNode("Calibration/@ScreenWidth").Value;
                            string screenHeight = client.SelectSingleNode("Calibration/@ScreenHeight").Value;
                            CalibrationData calibrationData = new CalibrationData(offsetInchesX, offsetInchesY, orientation, screenWidth, screenHeight);
                            _calibrations[key] = calibrationData;
                            //Debug.WriteLine(string.Format("Client ({0}) calibration loaded:{1}{2}", clientId.ToString(), Environment.NewLine, calibrationData.ToString()));
                        }
                        Debug.WriteLineIf(DebugSettings.DEBUG_CALIBRATION, string.Format("{0} calibration{1} loaded", clients.Count, (clients.Count != 1 ? "s" : "")));
                    }
                }
            }
            catch (XmlException) { }
        }
 public void AddCalibration(TagData tag, CalibrationData calibration)
 {
     string key = KeyFromTagData(tag);
     _calibrations[key] = calibration;
     SaveData();
 }
 internal CalibrationData GetCurrentCalibration()
 {
     Point origo = GetOrigo();
     CalibrationData c = new CalibrationData();
     double offsetX = (origo.X - TagPosition.X) / 48;
     double offsetY = (origo.Y - TagPosition.Y) / 48;
     if (offsetX > 0) offsetX += 0.25;
     if (offsetY > 0) offsetY += 0.25;
     c.OffsetInches = new Vector(offsetX, offsetY);
     c.Width = ScreenWidth;
     c.Height = ScreenHeight;
     c.Orientation = TagOrientation;
     Debug.WriteLineIf(DebugSettings.DEBUG_CALIBRATION, c);
     Debug.WriteLineIf(DebugSettings.DEBUG_CALIBRATION, "GetCurrentCalibration: this.Visualizer == null?: " + (_parent.Visualizer == null));
     return c;
 }