Beispiel #1
0
        private async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            Log.Debug("[MainPage_Loaded] Intialize ...");

            await IntializeFileOperations();

            SpaceFrame.Navigate(typeof(SpacePage));
            SpacePage = SpacePage.Self;

            LayerFrame.Navigate(typeof(LayerPage));
            LayerPage = LayerPage.Self;

            //Start SocketClient
            MaskManager.GetInstance().ShowMask(MaskType.NoSupportDevice);
            Log.Debug("[MainPage_Loaded] Start client thread");
            startclient();
            Log.Debug("[MainPage_Loaded] Start client thread complete");
            LoadSettings();
            Log.Debug("[MainPage_Loaded] LoadSettings complete");
            DeviceUpdatesPage.Self.UpdateButton_Click(null, null);

            var visibleBounds = ApplicationView.GetForCurrentView().VisibleBounds;

            ResizeButton(visibleBounds.Width);
        }
Beispiel #2
0
        private void SortDeviceButton_Click(object sender, RoutedEventArgs e)
        {
            EditDoneButton.IsEnabled = true;
            EditBarTextBlock.Text    = resourceLoader.GetString("SortDeviceTitle");
            MaskManager.GetInstance().ShowMask(MaskType.Editing);
            SpacePage.SetSpaceStatus(SpaceStatus.Sorting);

            oldSortingPositions.Clear();
            foreach (var dm in SpacePage.DeviceModelCollection)
            {
                oldSortingPositions.Add(dm, new Point(dm.PixelLeft, dm.PixelTop));
            }
        }
Beispiel #3
0
        private void EditDoneButton_Click(object sender, RoutedEventArgs e)
        {
            if (SpacePage.GetSpaceStatus() == SpaceStatus.ReEditing)
            {
                LayerModel          layer    = LayerPage.CheckedLayer;
                DeviceZonesPairList oldpairs = new DeviceZonesPairList();
                DeviceZonesPairList newpairs = new DeviceZonesPairList();

                foreach (DeviceModel dm in SpacePage.DeviceModelCollection)
                {
                    var oldzones = layer.GetDeviceZones(dm.Type);
                    oldpairs.Add(new DevicZonesPair(dm.Type, oldzones));

                    List <int> selectedIndex = new List <int>();

                    foreach (var zone in dm.AllZones)
                    {
                        if (zone.Selected == true)
                        {
                            selectedIndex.Add(zone.Index);
                        }
                    }

                    layer.SetDeviceZones(dm.Type, selectedIndex.ToArray());
                    newpairs.Add(new DevicZonesPair(dm.Type, selectedIndex.ToArray()));
                }

                ReUndoManager.Store(new EditZonesCommand(layer, oldpairs, newpairs));
                SpacePage.WatchLayer(layer);
            }
            else // Sorting
            {
                var dmPositions = new Dictionary <DeviceModel, Tuple <double, double> >();

                foreach (var pair in oldSortingPositions)
                {
                    DeviceModel dm    = pair.Key;
                    double      moveX = dm.PixelLeft - pair.Value.X;
                    double      moveY = dm.PixelTop - pair.Value.Y;

                    SpacePage.Self.DeleteOverlappingTempDevice(dm);
                    SpacePage.Self.MoveMousePosition(dm, RoundToGrid(moveX), RoundToGrid(moveY));
                    dmPositions.Add(dm, new Tuple <double, double>(moveX, moveY));
                }

                ReUndoManager.Store(new MoveDevicesCommand(dmPositions));
                SpacePage.GoToBlankEditing();
            }

            MaskManager.GetInstance().ShowMask(MaskType.None);
        }
Beispiel #4
0
        private void EditCancelButton_Click(object sender, RoutedEventArgs e)
        {
            if (SpacePage.GetSpaceStatus() == SpaceStatus.ReEditing)
            {
                LayerModel layer = LayerPage.CheckedLayer;
                SpacePage.WatchLayer(layer);
            }
            else // Sorting
            {
                SpacePage.GoToBlankEditing();

                foreach (var pair in oldSortingPositions)
                {
                    pair.Key.PixelLeft = pair.Value.X;
                    pair.Key.PixelTop  = pair.Value.Y;
                }
            }

            SpacePage.StopScrollTimer();
            MaskManager.GetInstance().ShowMask(MaskType.None);
        }
Beispiel #5
0
        public async Task Rescan()
        {
            try
            {
                Log.Debug("[Rescan] Start !");

                List <DeviceModel> remainDMs  = new List <DeviceModel>(DeviceModelCollection);
                List <DeviceModel> newDMs     = new List <DeviceModel>();
                string             deviceList = await GetPluggedDevicesFromService();

                string[] deviceArray = deviceList.Split(':');

                foreach (var deviceString in deviceArray)
                {
                    if (deviceString == "")
                    {
                        continue;
                    }

                    string[] deviceData = deviceString.Split(',');

                    if (deviceData.Length != 6)
                    {
                        Log.Debug("[Rescan] Invalid device info : " + deviceArray);
                        continue;
                    }

                    var get = DeviceModelCollection.Find(find => find.ModelName == deviceData[0]);
                    if (get == null)
                    {
                        DeviceModel dm = await DeviceModel.ToDeviceModelAsync(
                            deviceData[0], deviceData[1], deviceData[2],
                            deviceData[3], deviceData[4], deviceData[5]);

                        if (dm != null)
                        {
                            newDMs.Add(dm);
                        }
                    }
                    else
                    {
                        if (deviceData[5] == "true")
                        {
                            get.Plugged = true;
                            get.Sync    = true;
                        }
                        else if (deviceData[5] == "false")
                        {
                            get.Plugged = true;
                            get.Sync    = false;
                        }

                        remainDMs.Remove(get);
                    }
                }

                foreach (var dm in newDMs)
                {
                    Rect  r = new Rect(0, 0, dm.PixelWidth, dm.PixelHeight);
                    Point p = GetFreeRoomPositionForRect(r);
                    dm.PixelLeft = p.X;
                    dm.PixelTop  = p.Y;
                    dm.Plugged   = true;

                    // Delete temp data as same type as new, because new device is plugging
                    LayerPage.Self.ClearDeviceData(dm.Type);

                    if (dm.Type == (int)DeviceType.Notebook || dm.Type == (int)DeviceType.Desktop)
                    {
                        DeviceModelCollection.Insert(0, dm);
                    }
                    else
                    {
                        DeviceModelCollection.Add(dm);
                    }
                }

                // The rest mean device was unplugged
                foreach (var dm in remainDMs)
                {
                    dm.Plugged = false;
                }

                RefreshStage();
                NotifyConnectedDialog();
            }
            catch
            {
                MaskManager.GetInstance().ShowMask(MaskType.NoSupportDevice);
                Log.Debug("[Rescan] Rescan pluggeddevices failed !");
            }
        }
Beispiel #6
0
        public void RefreshStage()
        {
            List <MouseDetectedRegion> regions = new List <MouseDetectedRegion>();

            SpaceCanvas.Children.Clear();
            SpaceCanvas.Children.Add(GridImage);
            SpaceCanvas.Children.Add(RestrictLineLeft);
            SpaceCanvas.Children.Add(RestrictLineRight);
            SpaceCanvas.Children.Add(RestrictLineTop);
            SpaceCanvas.Children.Add(RestrictLineBottom);
            SpaceCanvas.Children.Add(MouseRectangle);

            var onStageList = DeviceModelCollection.FindAll(d => d.Plugged == true && d.Sync == true);

            foreach (var dm in onStageList)
            {
                List <ZoneModel> allzones = dm.AllZones;
                SortByZIndex(allzones);

                foreach (var zone in allzones)
                {
                    Rect relative = zone.GetRect();
                    Rect absolute = new Rect(
                        new Point(relative.Left + dm.PixelLeft, relative.Top + dm.PixelTop),
                        new Point(relative.Right + dm.PixelLeft, relative.Bottom + dm.PixelTop)
                        );

                    MouseDetectedRegion r = new MouseDetectedRegion()
                    {
                        RegionIndex   = -1,
                        DetectionRect = absolute,
                        GroupIndex    = dm.Type
                    };

                    r.Callback = zone.OnReceiveMouseEvent;

                    regions.Add(r);
                }

                DeviceView view = new DeviceView();
                view.DataContext = dm;
                SpaceCanvas.Children.Add(view);
            }

            m_MouseEventCtrl.DetectionRegions = regions.ToArray();
            GoToBlankEditing();
            StopScrollTimer();


            if (DeviceModelCollection.FindAll(find => find.Plugged == true).Count == 0)
            {
                MaskManager.GetInstance().ShowMask(MaskType.NoSupportDevice);
            }
            else if (DeviceModelCollection.Find(find => find.Sync == true) == null)
            {
                MaskManager.GetInstance().ShowMask(MaskType.NoSyncDevice);
            }
            else
            {
                MaskManager.GetInstance().ShowMask(MaskType.None);
            }
        }
Beispiel #7
0
 private void HideMask()
 {
     MaskManager.GetInstance().ShowMask(MaskType.None);
 }
Beispiel #8
0
 public void ShowReEditMask(LayerModel layer)
 {
     EditBarTextBlock.Text = resourceLoader.GetString("EditLayerText") + layer.Name;
     MaskManager.GetInstance().ShowMask(MaskType.Editing);
 }