private void AddToScheme(SubSchemeElement element)
        {
            if ((element.Width <= 0) || (element.Height <= 0) || (element.Left > PlanWidth) || (element.Top > PlanHeight))
            {
                return;
            }

            Color color1 = Color.FromHex(element.HexColor);

            if (color1 == (Color)Application.Current.Resources["SchemeBlockWhiteColor"])
            {
                color1 = (Color)Application.Current.Resources["SchemeBlockWhiteColorDark"];
            }

            int left   = Math.Max(0, Math.Min(PlanWidth, element.Left));
            int right  = Math.Min(PlanWidth, element.Left + element.Width);
            int top    = Math.Max(0, Math.Min(PlanHeight, element.Top));
            int bottom = Math.Min(PlanHeight, element.Top + element.Height);

            maingrid.Children.Add(
                new BoxView()
            {
                Opacity         = 0.7,
                BackgroundColor = color1
            }, left, right, top, bottom);
        }
        private void ShowSelection(SubSchemeElement element)
        {
            if (element.Selection is List <SubSchemeSelect> )
            {
                foreach (SubSchemeSelect sss in element.Selection)
                {
                    int selectLeft = 0;
                    int selectTop  = 0;
                    switch (element.RackOrientation)
                    {
                    case RackOrientationEnum.Undefined:
                        break;

                    case RackOrientationEnum.HorizontalLeft:
                    {
                        selectLeft = element.Left + sss.Section;
                        selectTop  = element.Top + sss.Depth - 1;
                        break;
                    }

                    case RackOrientationEnum.HorizontalRight:
                    {
                        selectLeft = element.Left + element.Width - sss.Section;
                        selectTop  = element.Top + sss.Depth - 1;
                        break;
                    }

                    case RackOrientationEnum.VerticalDown:
                    {
                        selectLeft = element.Left + sss.Depth - 1;
                        selectTop  = element.Top + element.Height - sss.Section;
                        break;
                    }

                    case RackOrientationEnum.VerticalUp:
                    {
                        selectLeft = element.Left + sss.Depth - 1;
                        selectTop  = element.Top + sss.Section - 1;
                        break;
                    }

                    default:
                        throw new InvalidOperationException("Impossible value");
                    }

                    if ((selectLeft < 0) || (selectTop < 0) || (selectLeft > PlanWidth) || (selectTop > PlanHeight))
                    {
                        break;
                    }

                    maingrid.Children.Add(
                        new BoxView()
                    {
                        BackgroundColor = Color.Red
                    }, selectLeft, selectTop);
                }
            }
        }
Example #3
0
 private void FillRacks(List <Rack> racks)
 {
     SubSchemeElements.Clear();
     foreach (Rack rack in racks)
     {
         SubSchemeElement sse = CreateSSE(rack);
         CheckGlobalSearch(rack, sse);
         SubSchemeElements.Add(sse);
     }
     RacksIsLoaded = SubSchemeElements.Count > 0;
 }
Example #4
0
        public async Task LoadRacks()
        {
            if (IsEditMode)
            {
                return;
            }

            RacksIsLoaded      = false;
            RacksIsBeingLoaded = true;
            try
            {
                List <Rack> racks = await NAV.GetRackList(LocationCode, Code, true, 1, int.MaxValue, ACD.Default).ConfigureAwait(true);

                if (!IsDisposed)
                {
                    SubSchemeElements.Clear();
                    foreach (Rack rack in racks)
                    {
                        SubSchemeElement sse = CreateSSE(rack);

                        if (Global.SearchResponses is List <SearchResponse> )
                        {
                            List <SearchResponse> list = Global.SearchResponses.FindAll(x => x.ZoneCode == Code && x.RackNo == rack.No);
                            if (list is List <SearchResponse> )
                            {
                                sse.Selection = new List <SubSchemeSelect>();
                                foreach (SearchResponse sr in list)
                                {
                                    SubSchemeSelect sss = new SubSchemeSelect
                                    {
                                        Section = sr.Section,
                                        Level   = sr.Level,
                                        Depth   = sr.Depth
                                    };
                                    sse.Selection.Add(sss);
                                }
                            }
                        }
                        SubSchemeElements.Add(sse);
                    }
                    RacksIsLoaded = SubSchemeElements.Count > 0;
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }
            finally
            {
                RacksIsBeingLoaded = false;
            }
        }
Example #5
0
 private void AddSubSchemeElements(List <Zone> zones)
 {
     SubSchemeElements.Clear();
     foreach (Zone zone in zones)
     {
         SubSchemeElement sse = new SubSchemeElement
         {
             Text     = zone.Description,
             Left     = zone.Left,
             Top      = zone.Top,
             Height   = zone.Height,
             Width    = zone.Width,
             HexColor = zone.HexColor
         };
         SubSchemeElements.Add(sse);
     }
     ZonesIsLoaded = SubSchemeElements.Count > 0;
 }
        private void AddToScheme(SubSchemeElement element)
        {
            if ((element.Width <= 0) || (element.Height <= 0) || (element.Left > PlanWidth) || (element.Top > PlanHeight))
            {
                return;
            }

            Color color1 = Color.FromHex(element.HexColor);

            if (color1 == (Color)Application.Current.Resources["SchemeBlockWhiteColor"])
            {
                color1 = Color.WhiteSmoke;
            }

            int left   = Math.Max(0, Math.Min(PlanWidth, element.Left));
            int right  = Math.Min(PlanWidth, element.Left + element.Width);
            int top    = Math.Max(0, Math.Min(PlanHeight, element.Top));
            int bottom = Math.Min(PlanHeight, element.Top + element.Height);

            if (SchemeType == 0)
            {
                maingrid.Children.Add(
                    new BoxView()
                {
                    Opacity         = 0.5,
                    BackgroundColor = color1
                }, left, right, top, bottom);
            }
            else
            {
                maingrid.Children.Add(
                    new Label()
                {
                    FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                    Text     = element.Text,
                    Opacity  = 0.5,
                    HorizontalTextAlignment = TextAlignment.Center,
                    VerticalTextAlignment   = TextAlignment.Center,
                    BackgroundColor         = color1
                }, left, right, top, bottom);
            }
        }
Example #7
0
        public async Task LoadZones()
        {
            if (IsEditMode)
            {
                return;
            }

            ZonesIsLoaded      = false;
            ZonesIsBeingLoaded = true;
            try
            {
                List <Zone> zones = await NAV.GetZoneList(Code, "", true, 1, int.MaxValue, ACD.Default);

                if (!IsDisposed)
                {
                    SubSchemeElements.Clear();
                    foreach (Zone zone in zones)
                    {
                        SubSchemeElement sse = new SubSchemeElement
                        {
                            Left     = zone.Left,
                            Top      = zone.Top,
                            Height   = zone.Height,
                            Width    = zone.Width,
                            HexColor = zone.HexColor
                        };
                        SubSchemeElements.Add(sse);
                    }
                    ZonesIsLoaded = SubSchemeElements.Count > 0;
                }
            }
            catch (OperationCanceledException e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
                ErrorText = e.Message;
            }
            finally
            {
                ZonesIsBeingLoaded = false;
            }
        }
Example #8
0
 private void CheckGlobalSearch(Rack rack, SubSchemeElement sse)
 {
     if (Global.SearchResponses is List <SearchResponse> )
     {
         List <SearchResponse> list = Global.SearchResponses.FindAll(x => x.ZoneCode == Code && x.RackID == rack.ID);
         if (list is List <SearchResponse> )
         {
             sse.Selection = new List <SubSchemeSelect>();
             foreach (SearchResponse sr in list)
             {
                 SubSchemeSelect sss = new SubSchemeSelect
                 {
                     Section = sr.Section,
                     Level   = sr.Level,
                     Depth   = sr.Depth
                 };
                 sse.Selection.Add(sss);
             }
         }
     }
 }