Ejemplo n.º 1
0
        private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            AllowSuspensionDetail = false;
            DefaultZoomLevel      = 13;
            IsZoomed = false;
            IsLoaded = true;
            isSpecificRamalCalled = false;
            SpecificRamal         = Guid.Empty;

            PinsArray = new List <EPL_WS.GET_Suspensions_FullDetailed_Result>();

            SB_Breadcrumb_Title_Close.Completed += new EventHandler(SB_Breadcrumb_Title_Close_Completed);

            TB_SubTitle.Text = DateHandler.GetDateFormatted(DateTime.Now).ToUpper();

            ShowAllPins = true;

            MaxGrapshWidth  = 1356;
            MaxGrapshHeight = 640;

            // ========== "LOAD" COLORS ==========
            PinBackgroundColorNormal = new LinearGradientBrush
            {
                EndPoint      = new Point(0.5, 1),
                StartPoint    = new Point(0.5, 0),
                GradientStops = new GradientStopCollection
                {
                    new GradientStop {
                        Color = ColorHandler.HexColor("#3D8939"), Offset = 0
                    },
                    new GradientStop {
                        Color = ColorHandler.HexColor("#068700"), Offset = 1
                    }
                }
            };

            PinBackgroundColorApproved = new LinearGradientBrush
            {
                EndPoint      = new Point(0.5, 1),
                StartPoint    = new Point(0.5, 0),
                GradientStops = new GradientStopCollection
                {
                    new GradientStop {
                        Color = ColorHandler.HexColor("#FF8C0A"), Offset = 0
                    },
                    new GradientStop {
                        Color = ColorHandler.HexColor("#FFFF5D00"), Offset = 1
                    }
                }
            };

            PinBackgroundColorExecution = new LinearGradientBrush
            {
                EndPoint      = new Point(0.5, 1),
                StartPoint    = new Point(0.5, 0),
                GradientStops = new GradientStopCollection
                {
                    new GradientStop {
                        Color = ColorHandler.HexColor("#FFD40000"), Offset = 0
                    },
                    new GradientStop {
                        Color = ColorHandler.HexColor("#FF800000"), Offset = 1
                    }
                }
            };

            PinBackgroundColorConcluded = new LinearGradientBrush
            {
                EndPoint      = new Point(0.5, 1),
                StartPoint    = new Point(0.5, 0),
                GradientStops = new GradientStopCollection
                {
                    new GradientStop {
                        Color = ColorHandler.HexColor("#3D8939"), Offset = 0
                    },
                    new GradientStop {
                        Color = ColorHandler.HexColor("#068700"), Offset = 1
                    }
                }
            };
            // ===================================

            m_PushpinLayer = new MapLayer();
            m_ControlLayer = new MapLayer();

            // Draw on Map
            MiraMap.Children.Add(m_PushpinLayer);
            MiraMap.Children.Add(m_ControlLayer);

            // Default Zoom Level
            MiraMap.ZoomLevel = 13.0;

            // Default Center - EPAL
            MiraMap.Center = new Location(38.722584, -9.158435);

            // Timer to Reload 'Ramais' after map changed events
            DrawMapTimer          = new DispatcherTimer();
            DrawMapTimer.Interval = new TimeSpan(0, 0, 0, 2, 0);
            DrawMapTimer.Tick    += DrawMapTimer_CallBack;

            // Timer to Reload 'Ramais' after a certain timespan
            RefreshMapTimer          = new DispatcherTimer();
            RefreshMapTimer.Interval = new TimeSpan(0, 0, 0, 30, 0);
            RefreshMapTimer.Tick    += RefreshMapTimer_CallBack;

            AllowTimersTick = false;

            if (GetParam("Type") != null)
            {
                int type = 0;
                int.TryParse(GetParam("Type"), out type);
                CB_Year.SelectedIndex = type;
            }

            int frameType = 0;

            if (GetParam("Frame") != null && int.TryParse(GetParam("Frame"), out frameType))
            {
                SP_Content.Margin           = new Thickness(2, -3, 2, 2);
                BRD_Top.Visibility          = Visibility.Collapsed;
                BRD_Graphs.BorderThickness  = new Thickness(0);
                MiraMap.CopyrightVisibility = Visibility.Collapsed;
            }

            int enabled = 0;

            if (GetParam("Enabled") != null && int.TryParse(GetParam("Enabled"), out enabled))
            {
                MiraMap.IsEnabled = enabled == 1;
            }

            int nav = 0;

            if (GetParam("Nav") != null && int.TryParse(GetParam("Nav"), out nav))
            {
                MiraMap.NavigationVisibility = (nav == 0) ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible;
            }

            ID_Suspension = 0;

            if (GetParam("ID") != null && long.TryParse(GetParam("ID"), out ID_Suspension))
            {
                AllowSuspensionDetail      = true;
                TB_Title.Text              = string.Format("SUSPENSÃO {0}", ID_Suspension);
                CB_Year.IsEnabled          = false;
                TB_Search.IsEnabled        = false;
                SP_FilterSearch.Visibility = Visibility.Collapsed;
            }

            GetSuspensions();
        }