iSpyApplication.MainForm.SaveObjects C# (CSharp) Method

SaveObjects() private method

private SaveObjects ( string fileName ) : void
fileName string
return void
        private void SaveObjects(string fileName)
        {
            if (_shuttingDown)
                return;

            if (fileName == "")
                fileName = Program.AppDataPath + @"XML\objects.xml";
            var c = new objects { Version = Convert.ToInt32(Application.ProductVersion.Replace(".", "")), actions = new objectsActions {entries = _actions.ToArray()} };
            foreach (objectsCamera oc in Cameras)
            {
                CameraWindow occ = GetCameraWindow(oc.id);
                if (occ != null)
                {
                    oc.width = occ.Width;
                    oc.height = occ.Height;
                    oc.x = occ.Location.X;
                    oc.y = occ.Location.Y;
                }
            }
            c.cameras = Cameras.ToArray();
            foreach (objectsMicrophone om in Microphones)
            {
                VolumeLevel omc = GetVolumeLevel(om.id);
                if (omc != null)
                {
                    om.width = omc.Width;
                    om.height = omc.Height;
                    om.x = omc.Location.X;
                    om.y = omc.Location.Y;
                }
            }
            c.microphones = Microphones.ToArray();
            foreach (objectsFloorplan of in FloorPlans)
            {
                FloorPlanControl fpc = GetFloorPlan(of.id);
                if (fpc != null)
                {
                    of.width = fpc.Width;
                    of.height = fpc.Height;
                    of.x = fpc.Location.X;
                    of.y = fpc.Location.Y;
                }
            }
            c.floorplans = FloorPlans.ToArray();
            c.remotecommands = RemoteCommands.ToArray();
            c.schedule = new objectsSchedule {entries = _schedule.ToArray()};
            lock (ThreadLock)
            {
                var s = new XmlSerializer(typeof(objects));
                var sb = new StringBuilder();
                using (var writer = new StringWriter(sb))
                {
                    try
                    {
                        s.Serialize(writer, c);
                        File.WriteAllText(fileName, sb.ToString(), Encoding.UTF8);
                    }
                    catch (Exception e)
                    {
                        Logger.LogExceptionToFile(e);
                    }
                }
            }
            _currentFileName = fileName;
        }
MainForm