コード例 #1
0
ファイル: DevicesView.xaml.cs プロジェクト: hjlfmy/Rubezh
        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;
        }
コード例 #2
0
		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);
		}
コード例 #3
0
ファイル: Helper.cs プロジェクト: saeednazari/Rubezh
		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);
		}
コード例 #4
0
ファイル: Helper.cs プロジェクト: hjlfmy/Rubezh
 public static Device SetDevice(ElementDevice element)
 {
     Device device = GetDevice(element);
     if (device != null)
         device.PlanElementUIDs.Add(element.UID);
     return device;
 }
コード例 #5
0
ファイル: PlanMonitor.cs プロジェクト: saeednazari/Rubezh
		private void Initialize(ElementDevice element)
		{
			var device = Helper.GetDevice(element);
			if (device != null)
			{
				_deviceStates.Add(device.DeviceState);
				device.DeviceState.StateChanged += _callBack;
			}
		}
コード例 #6
0
ファイル: ElementDevice.cs プロジェクト: hjlfmy/Rubezh
 public override ElementBase Clone()
 {
     ElementDevice elementBase = new ElementDevice()
     {
         DeviceUID = DeviceUID
     };
     Copy(elementBase);
     return elementBase;
 }
コード例 #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);
            }
        }
コード例 #8
0
ファイル: DevicePainter.cs プロジェクト: saeednazari/Rubezh
		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();
		}
コード例 #9
0
		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");
			}
		}
コード例 #10
0
ファイル: Helper.cs プロジェクト: saeednazari/Rubezh
		public static Device GetDevice(ElementDevice element)
		{
			return element.DeviceUID != Guid.Empty && _deviceMap.ContainsKey(element.DeviceUID) ? _deviceMap[element.DeviceUID] : null;
		}
コード例 #11
0
ファイル: Helper.cs プロジェクト: saeednazari/Rubezh
		public static void ResetDevice(ElementDevice element)
		{
			Device device = GetDevice(element);
			if (device != null)
				device.PlanElementUIDs.Remove(element.UID);
		}
コード例 #12
0
ファイル: Helper.cs プロジェクト: saeednazari/Rubezh
		public static Device SetDevice(ElementDevice element)
		{
			Device device = GetDevice(element);
			SetDevice(element, device);
			return device;
		}
コード例 #13
0
ファイル: Helper.cs プロジェクト: saeednazari/Rubezh
		public static string GetDeviceTitle(ElementDevice element)
		{
			var device = GetDevice(element);
			return device == null ? "Неизвестное устройство" : device.DottedPresentationAddressAndName;
		}
コード例 #14
0
ファイル: Helper.cs プロジェクト: hjlfmy/Rubezh
 public static void SetDevice(ElementDevice element, Device device)
 {
     ResetDevice(element);
     element.DeviceUID = device.UID;
     device.PlanElementUIDs.Add(element.UID);
 }
コード例 #15
0
ファイル: Helper.cs プロジェクト: hjlfmy/Rubezh
 public static string GetDeviceTitle(ElementDevice element)
 {
     var device = GetDevice(element);
     return device == null ? "Неизвестное устройство" : device.DottedAddress + " " + device.Driver.ShortName;
 }
コード例 #16
0
ファイル: Helper.cs プロジェクト: hjlfmy/Rubezh
 public static Device GetDevice(ElementDevice element)
 {
     return element.DeviceUID == null ? null : FiresecManager.Devices.FirstOrDefault(x => x.UID == element.DeviceUID);
 }