Interaction logic for DeviceItem.xaml
Inheritance: System.Windows.Controls.UserControl
コード例 #1
0
        private void DeviceItem_EditDevice(Controls.DeviceItem item)
        {
            var data = new EventData(this);

            data.Id     = "SHOW_EDIT_DEVICE";
            data.Data01 = item.Device;
            SendData?.Invoke(data);
        }
コード例 #2
0
        private void DeviceItem_ViewDetails(Controls.DeviceItem item)
        {
            var data = new EventData(this);

            data.Id     = "OPEN_DEVICE_DETAILS";
            data.Data01 = item.Device;
            SendData?.Invoke(data);
        }
コード例 #3
0
        private Controls.DeviceItem AddDeviceItem(DeviceDescription device)
        {
            var deviceItem = new Controls.DeviceItem(this, device);

            deviceItem.Moved        += DeviceItem_Updated;
            deviceItem.Resized      += DeviceItem_Updated;
            deviceItem.ViewDetails  += DeviceItem_ViewDetails;
            deviceItem.EditDevice   += DeviceItem_EditDevice;
            deviceItem.CloseClicked += DeviceItem_CloseClicked;

            // Add to Canvas
            shopCanvas.Children.Add(deviceItem);

            // Add to DeviceItems collection (to update data)
            DeviceItems.Add(deviceItem);

            return(deviceItem);
        }
コード例 #4
0
        private void SaveDeviceItemLocation(Controls.DeviceItem deviceItem)
        {
            List <DeviceItemLocation> locations = null;

            var json = Properties.Settings.Default.ShopStatusItemLocations;

            if (!string.IsNullOrEmpty(json))
            {
                locations = JSON.ToType <List <DeviceItemLocation> >(json);
            }

            if (locations == null)
            {
                locations = new List <DeviceItemLocation>();
            }

            double x = Canvas.GetLeft(deviceItem);
            double y = Canvas.GetTop(deviceItem);

            double width  = deviceItem.ActualWidth;
            double height = deviceItem.ActualHeight;

            var location = locations.Find(o => o.DeviceId == deviceItem.Device.UniqueId);

            if (location == null)
            {
                location = new DeviceItemLocation();
                locations.Add(location);
            }

            location.DeviceId = deviceItem.Device.UniqueId;
            location.X        = x;
            location.Y        = y;
            location.Height   = height;
            location.Width    = width;

            json = JSON.FromList <DeviceItemLocation>(locations);
            if (!string.IsNullOrEmpty(json))
            {
                Properties.Settings.Default.ShopStatusItemLocations = json;
                Properties.Settings.Default.Save();
            }
        }
コード例 #5
0
        private void RemoveDeviceItemLocation(Controls.DeviceItem deviceItem)
        {
            var json = Properties.Settings.Default.ShopStatusItemLocations;

            if (!string.IsNullOrEmpty(json))
            {
                var locations = JSON.ToType <List <DeviceItemLocation> >(json);

                int i = locations.FindIndex(o => o.DeviceId == deviceItem.Device.UniqueId);
                if (i >= 0)
                {
                    locations.RemoveAt(i);
                }

                json = JSON.FromList <DeviceItemLocation>(locations);
                if (!string.IsNullOrEmpty(json))
                {
                    Console.WriteLine(json);

                    Properties.Settings.Default.ShopStatusItemLocations = json;
                    Properties.Settings.Default.Save();
                }
            }
        }
コード例 #6
0
 private void DeviceItem_Updated(Controls.DeviceItem item)
 {
     SaveDeviceItemLocation(item);
 }
コード例 #7
0
 private void DeviceItem_CloseClicked(Controls.DeviceItem item)
 {
     AddListItem(item.Device);
     RemoveDeviceItem(item);
 }
コード例 #8
0
 private void RemoveDeviceItem(Controls.DeviceItem deviceItem)
 {
     shopCanvas.Children.Remove(deviceItem);
     DeviceItems.Remove(deviceItem);
     RemoveDeviceItemLocation(deviceItem);
 }
コード例 #9
0
        private Controls.DeviceItem AddDeviceItem(DeviceDescription device)
        {
            var deviceItem = new Controls.DeviceItem(this, device);
            deviceItem.Moved += DeviceItem_Updated;
            deviceItem.Resized += DeviceItem_Updated;
            deviceItem.ViewDetails += DeviceItem_ViewDetails;
            deviceItem.EditDevice += DeviceItem_EditDevice;
            deviceItem.CloseClicked += DeviceItem_CloseClicked;

            // Add to Canvas
            shopCanvas.Children.Add(deviceItem);

            // Add to DeviceItems collection (to update data)
            DeviceItems.Add(deviceItem);

            return deviceItem;
        }