Ejemplo n.º 1
0
        private void On_MouseMove(object sender, MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (e.LeftButton != MouseButtonState.Pressed)
            {
                this.dragStartPoint = null;
            }

            if (this.dragStartPoint.HasValue)
            {
                DeviceViewModel viewModel = (sender as Image).DataContext as DeviceViewModel;
                //if (viewModel.DesignerCanvas != null)
                //    viewModel.DesignerCanvas.Toolbox.SetDefault();
                var device = viewModel.Device;
                if (device.Driver.IsPlaceable == false)
                    return;

                if (FiresecManager.LibraryConfiguration.Devices.Any(x => x.DriverId == device.DriverUID) == false)
                    return;

                ElementBase plansElement = new ElementDevice()
                {
                    DeviceUID = device.UID
                };

                var dataObject = new DataObject("DESIGNER_ITEM", plansElement);
                DragDrop.DoDragDrop(this, dataObject, DragDropEffects.Copy);
            }

            e.Handled = true;
        }
		public DevicePropertiesViewModel(DevicesViewModel devicesViewModel, ElementDevice elementDevice)
		{
			Title = "Свойства фигуры: Устройство";
			_elementDevice = elementDevice;
			_devicesViewModel = devicesViewModel;

			Devices = new ObservableCollection<DeviceViewModel>();
			foreach (var device in FiresecManager.Devices)
			{
				var deviceViewModel = new DeviceViewModel(device);
				deviceViewModel.IsExpanded = true;
				Devices.Add(deviceViewModel);
			}
			foreach (var device in Devices)
			{
				if (device.Device.Parent != null)
				{
					var parent = Devices.FirstOrDefault(x => x.Device.UID == device.Device.Parent.UID);
					parent.AddChild(device);
				}
			}

			if (Devices.Count > 0)
			{
				CollapseChild(Devices[0]);
				ExpandChild(Devices[0]);
			}

			SelectedDriver = FiresecManager.DeviceLibraryConfiguration.Devices.FirstOrDefault(x => x.DriverId == _elementDevice.AlternativeLibraryDeviceUID);
			Select(elementDevice.DeviceUID);
		}
Ejemplo n.º 3
0
		public static void SetDevice(ElementDevice element, Device device)
		{
			ResetDevice(element);
			element.DeviceUID = device == null ? Guid.Empty : device.UID;
			if (device != null)
				device.PlanElementUIDs.Add(element.UID);
		}
Ejemplo n.º 4
0
 public static Device SetDevice(ElementDevice element)
 {
     Device device = GetDevice(element);
     if (device != null)
         device.PlanElementUIDs.Add(element.UID);
     return device;
 }
Ejemplo n.º 5
0
		private void Initialize(ElementDevice element)
		{
			var device = Helper.GetDevice(element);
			if (device != null)
			{
				_deviceStates.Add(device.DeviceState);
				device.DeviceState.StateChanged += _callBack;
			}
		}
Ejemplo n.º 6
0
 public override ElementBase Clone()
 {
     ElementDevice elementBase = new ElementDevice()
     {
         DeviceUID = DeviceUID
     };
     Copy(elementBase);
     return elementBase;
 }
Ejemplo n.º 7
0
        public ElementDeviceViewModel(ElementDevice elementDevice)
        {
            ShowInTreeCommand = new RelayCommand(OnShowInTree);
            DisableCommand = new RelayCommand(OnDisable, CanDisable);
            ShowPropertiesCommand = new RelayCommand(OnShowProperties);

            ElementDevice = elementDevice;
            DeviceUID = elementDevice.DeviceUID;
            Device = FiresecManager.Devices.FirstOrDefault(x => x.UID == elementDevice.DeviceUID);
            DeviceState = FiresecManager.DeviceStates.DeviceStates.FirstOrDefault(x => x.UID == elementDevice.DeviceUID);
            if (DeviceState != null)
            {
                DeviceState.StateChanged += new Action(OnDeviceStateChanged);
            }
        }
Ejemplo n.º 8
0
		public DevicePainter(PresenterItem presenterItem)
			: base(presenterItem.Element)
		{
			_contextMenu = null;
			_elementDevice = presenterItem.Element as ElementDevice;
			if (_elementDevice != null)
			{
				_device = Helper.GetDevice(_elementDevice);
				if (_device != null)
				{
					_device.DeviceState.StateChanged += OnPropertyChanged;
					_device.DeviceState.ParametersChanged += OnParametersChanged;
				}
			}
			_presenterItem = presenterItem;
			_presenterItem.IsPoint = true;
			_presenterItem.ShowBorderOnMouseOver = true;
			_presenterItem.ContextMenuProvider = CreateContextMenu;
			_presenterItem.Title = GetDeviceTooltip();
			_presenterItem.Cursor = Cursors.Hand;
			_presenterItem.ClickEvent += (s, e) => OnShowProperties();
		}
		void AddDevice(Plan plan, surfacesSurfaceLayerElementsElement innerElement, DeviceConfiguration deviceConfiguration)
		{
			try
			{
				if (innerElement.rect != null)
				{
					var innerRect = innerElement.rect[0];

					long longId = long.Parse(innerElement.id);
					int intId = (int)longId;

					var height = Parse(innerRect.bottom) - Parse(innerRect.top);
					var width = Parse(innerRect.right) - Parse(innerRect.left);
					var elementDevice = new ElementDevice()
					{
						Left = Parse(innerRect.left) + height / 2,
						Top = Parse(innerRect.top) + width / 2
					};
					plan.ElementDevices.Add(elementDevice);

					foreach (var device in deviceConfiguration.Devices)
					{
						foreach (var deviceShapeId in device.ShapeIds)
						{
							if ((deviceShapeId == longId.ToString()) || (deviceShapeId == intId.ToString()))
							{
								elementDevice.DeviceUID = device.UID;
								device.PlanElementUIDs.Add(elementDevice.UID);
							}
						}
					}
				}
			}
			catch (Exception e)
			{
				Logger.Error(e, "ConfigurationConverter.AddPolygonZone");
			}
		}
Ejemplo n.º 10
0
		public static Device GetDevice(ElementDevice element)
		{
			return element.DeviceUID != Guid.Empty && _deviceMap.ContainsKey(element.DeviceUID) ? _deviceMap[element.DeviceUID] : null;
		}
Ejemplo n.º 11
0
		public static void ResetDevice(ElementDevice element)
		{
			Device device = GetDevice(element);
			if (device != null)
				device.PlanElementUIDs.Remove(element.UID);
		}
Ejemplo n.º 12
0
		public static Device SetDevice(ElementDevice element)
		{
			Device device = GetDevice(element);
			SetDevice(element, device);
			return device;
		}
Ejemplo n.º 13
0
		public static string GetDeviceTitle(ElementDevice element)
		{
			var device = GetDevice(element);
			return device == null ? "Неизвестное устройство" : device.DottedPresentationAddressAndName;
		}
Ejemplo n.º 14
0
 public static void SetDevice(ElementDevice element, Device device)
 {
     ResetDevice(element);
     element.DeviceUID = device.UID;
     device.PlanElementUIDs.Add(element.UID);
 }
Ejemplo n.º 15
0
 public static string GetDeviceTitle(ElementDevice element)
 {
     var device = GetDevice(element);
     return device == null ? "Неизвестное устройство" : device.DottedAddress + " " + device.Driver.ShortName;
 }
Ejemplo n.º 16
0
 public static Device GetDevice(ElementDevice element)
 {
     return element.DeviceUID == null ? null : FiresecManager.Devices.FirstOrDefault(x => x.UID == element.DeviceUID);
 }