public DeviceConfigurationViewModel(Guid deviceUID, DeviceConfiguration deviceConfiguration)
        {
            Title = "Сравнение конфигураций";
            ReplaceCommand = new RelayCommand(OnReplace);
            _deviceUID = deviceUID;
            _deviceConfiguration = deviceConfiguration;
            _deviceConfiguration.Update();
            foreach (var device in _deviceConfiguration.Devices)
            {
                device.Driver = FiresecManager.FiresecConfiguration.Drivers.FirstOrDefault(x => x.UID == device.DriverUID);
            }

            LocalRootDevice = FiresecManager.Devices.FirstOrDefault(x => x.UID == _deviceUID);
            RemoteRootDevice = _deviceConfiguration.Devices.FirstOrDefault(x => x.UID == _deviceUID);
            LocalDevices = new DeviceTreeViewModel(LocalRootDevice, FiresecManager.FiresecConfiguration.DeviceConfiguration);
            RemoteDevices = new DeviceTreeViewModel(RemoteRootDevice, _deviceConfiguration);
        }
        public void SelectDevice()
        {
            DeviceTreeViewModel newDeviceTreeViewModel = new DeviceTreeViewModel();
            newDeviceTreeViewModel.Initialize();
            DeviceTreeView newDeviceTreeView = new DeviceTreeView();
            newDeviceTreeView.DataContext = newDeviceTreeViewModel;
            newDeviceTreeViewModel.Closing += newDeviceTreeView.Close;

            newDeviceTreeView.ShowDialog();

            if (newDeviceTreeViewModel.DeviceId != Guid.Empty)
            {
                DeviceId = newDeviceTreeViewModel.DeviceId;
                Inicialize(DeviceId);
            }
        }
        public DeviceConfigurationViewModel(Guid deviceUID, DeviceConfiguration remoteDeviceConfiguration)
        {
            Title = "Сравнение конфигураций";
            ReplaceCommand = new RelayCommand(OnReplace);

            RemoteDeviceConfiguration = remoteDeviceConfiguration;
            RemoteDeviceConfiguration.Update();
            foreach (var device in RemoteDeviceConfiguration.Devices)
            {
                device.Driver = FiresecManager.Drivers.FirstOrDefault(x => x.UID == device.DriverUID);
                if (device.Driver == null)
                {
                    ;
                }
            }
            RemoteDeviceConfiguration.Reorder();
            RemoteDeviceConfiguration.InvalidateConfiguration();
            RemoteDeviceConfiguration.UpdateCrossReferences();

            LocalRootDevice = FiresecManager.Devices.FirstOrDefault(x => x.UID == deviceUID);
            RemoteRootDevice = RemoteDeviceConfiguration.Devices.FirstOrDefault(x => x.UID == deviceUID);

            LocalRootClone = (Device)FiresecManager.Devices.FirstOrDefault(x => x.UID == deviceUID).Clone();
            RemoteRootClone = (Device)RemoteDeviceConfiguration.Devices.FirstOrDefault(x => x.UID == deviceUID).Clone();

            LocalRootClone.Children = new List<Device>();
            if (LocalRootDevice.Children != null)
                foreach (var children in LocalRootDevice.Children)
                {
                    var childrenClone = (Device)children.Clone();
                    childrenClone.DeviceConfiguration = FiresecManager.FiresecConfiguration.DeviceConfiguration;
                    LocalRootClone.Children.Add(childrenClone);
                    if (children.Children != null)
                    {
                        var localchch =
                            LocalRootClone.Children.FirstOrDefault(
                                x =>
                                ((x.PresentationName == children.PresentationName) &&
                                 (x.AddressFullPath == children.AddressFullPath)));
                        localchch.Children = new List<Device>();
                        foreach (var chch in children.Children)
                        {
                            var chchClone = (Device)chch.Clone();
                            chchClone.DeviceConfiguration = FiresecManager.FiresecConfiguration.DeviceConfiguration;
                            localchch.Children.Add(chchClone);
                        }
                    }
                }

            RemoteRootClone.Children = new List<Device>();
            if (RemoteRootDevice.Children != null)
                foreach (var children in RemoteRootDevice.Children)
                {
                    var childrenClone = (Device)children.Clone();
                    childrenClone.DeviceConfiguration = RemoteDeviceConfiguration;
                    RemoteRootClone.Children.Add(childrenClone);
                    if (children.Children != null)
                    {
                        var remotechch =
                            RemoteRootClone.Children.FirstOrDefault(
                                x =>
                                ((x.PresentationName == children.PresentationName) &&
                                 (x.AddressFullPath == children.AddressFullPath)));
                        remotechch.Children = new List<Device>();
                        foreach (var chch in children.Children)
                        {
                            var chchClone = (Device)chch.Clone();
                            chchClone.DeviceConfiguration = RemoteDeviceConfiguration;
                            remotechch.Children.Add(chchClone);
                        }
                    }
                }

            IntoLocalDevice(LocalRootDevice, RemoteRootClone);
            IntoRemoteDevice(RemoteRootDevice, LocalRootClone);

            Sort(LocalRootClone);
            Sort(RemoteRootClone);

            LocalDevices = new DeviceTreeViewModel(LocalRootClone);
            RemoteDevices = new DeviceTreeViewModel(RemoteRootClone);
        }