Esempio n. 1
0
        private void EditFrame(FovFrame frame)
        {
            var viewModel = ViewManager.CreateViewModel <FovSettingsVM>();

            viewModel.Frame = frame;
            if (ViewManager.ShowDialog(viewModel) ?? false)
            {
                frame = viewModel.Frame;
                int index = fovFrames.FindIndex(f => f.Id == frame.Id);

                if (index >= 0)
                {
                    fovFrames.RemoveAt(index);
                    fovFrames.Insert(index, frame);
                }
                else
                {
                    fovFrames.Add(frame);
                }

                settings.Set("FovFrames", fovFrames);
                settings.Save();
                NotifyPropertyChanged(nameof(FovFrames), nameof(IsEmptyList));
            }
        }
Esempio n. 2
0
        private void DrawFovCircle(IMapContext map, float frameSize, FovFrame frame, bool isOuter)
        {
            float radius = frameSize * 3600 / 2;
            float size   = map.GetDiskSize(radius);

            // do not draw frame if its size exceeds screen bounds
            if (size < Math.Sqrt(map.Width * map.Width + map.Height * map.Height))
            {
                if (isOuter && frame.Shading > 0 && frameSize >= map.ViewAngle / 2)
                {
                    var circle = new GraphicsPath();
                    circle.AddEllipse(map.Width / 2 - size / 2, map.Height / 2 - size / 2, size, size);

                    var shading = new Region(new RectangleF(0, 0, map.Width, map.Height));
                    shading.Exclude(circle);

                    int transparency = (int)(frame.Shading / 100f * 255);
                    var solidBrush   = new SolidBrush(Color.FromArgb(transparency, map.GetSkyColor()));
                    map.Graphics.FillRegion(solidBrush, shading);
                }
                map.Graphics.DrawEllipse(new Pen(frame.Color.GetColor(map.Schema, map.DayLightFactor)), map.Width / 2 - size / 2, map.Height / 2 - size / 2, size, size);

                if (isOuter)
                {
                    float labelWidth = map.Graphics.MeasureString(frame.Label, font).Width;
                    if (labelWidth <= size * 2)
                    {
                        map.Graphics.DrawString(frame.Label, font, new SolidBrush(frame.Color.GetColor(map.Schema, map.DayLightFactor)), new PointF(map.Width / 2, map.Height / 2 + size / 2), format);
                    }
                }
            }
        }
Esempio n. 3
0
        private void DeleteFrame(FovFrame frame)
        {
            int index = fovFrames.FindIndex(f => f.Id == frame.Id);

            if (index >= 0)
            {
                if (ViewManager.ShowMessageBox("$FovFramesListWindow.WarningTitle", "$FovFramesListWindow.DeleteFrameWarningMessage", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    fovFrames.RemoveAt(index);
                    settings.SetAndSave("FovFrames", fovFrames);
                    NotifyPropertyChanged(nameof(FovFrames), nameof(IsEmptyList));
                }
            }
        }
Esempio n. 4
0
 private void CopyFrame(FovFrame frame)
 {
     EditFrame(frame.Copy());
 }
Esempio n. 5
0
 private void CheckedFrame(FovFrame frame)
 {
     settings.Set("FovFrames", fovFrames);
     settings.Save();
     map.Invalidate();
 }