コード例 #1
0
        static bool Run(string name, InterpBase func, InterpEnvironment env, DisplayMode display = DisplayMode.All)
        {
            try
            {
                func.Interp(env);

                if (display.HasFlag(DisplayMode.Success))
                {
                    Console.WriteLine(name);
                    WriteColour("\t[Passed]", GoodColour);
                }

                return(true);
            }
            catch (AssertFailException afe)
            {
                if (display.HasFlag(DisplayMode.Errors))
                {
                    Console.WriteLine(name);
                    WriteColour("\t[Failed]: " + afe.Message, FailColour);
                }
            }
            catch (WrongTypeException wte)
            {
                if (display.HasFlag(DisplayMode.Errors))
                {
                    Console.WriteLine(name);
                    WriteColour("\t[Failed]: " + wte.Message, IndeterminateColour);
                }
            }
            catch (UndefinedIdentifierException uie)
            {
                if (display.HasFlag(DisplayMode.Errors))
                {
                    Console.WriteLine(name);
                    WriteColour("\t[Failed]: " + uie.Message, IndeterminateColour);
                }
            }
            catch (Exception ex)
            {
                if (display.HasFlag(DisplayMode.Errors))
                {
                    Console.WriteLine(name);
                    WriteColour("\t[Failed]: " + ex.Message, IndeterminateColour);
                }
            }

            return(false);
        }
コード例 #2
0
        public virtual Task ShowModalAsync(Control parent)
        {
            var tcs = new TaskCompletionSource <bool>();

            session = null;
            if (parent != null && parent.ParentWindow != null)
            {
                var nswindow = parent.ParentWindow.ControlObject as NSWindow;
                if (nswindow != null)
                {
                    Control.ParentWindow = nswindow;
                }
            }
            Callback.OnShown(Widget, EventArgs.Empty);

            Widget.Closed += HandleClosed;
            if (DisplayMode.HasFlag(DialogDisplayMode.Attached))
            {
                MacModal.BeginSheet(Widget, Control, out session, () => tcs.SetResult(true));
            }
            else
            {
                Control.MakeKeyWindow();
                Application.Instance.AsyncInvoke(() =>
                {
                    MacModal.Run(Widget, Control, out session);
                    tcs.SetResult(true);
                });
            }
            return(tcs.Task);
        }
コード例 #3
0
        async Task ShowModalAsync(bool opening)
        {
            closedcs = new TaskCompletionSource <bool>();
            inNav    = false;
            var parent = Widget.Owner;

            if (parent != null && (DisplayMode.HasFlag(DialogDisplayMode.Navigation) || DisplayMode == DialogDisplayMode.Default))
            {
                var iosView = parent.Handler as IIosViewControllerSource;
                if (iosView != null && iosView.Controller != null)
                {
                    var nav = iosView.Controller.NavigationController;
                    if (nav != null)
                    {
                        nav.PushViewController(Controller, true);
                        inNav = true;
                    }
                }
            }
            if (!inNav)
            {
                Controller.ModalPresentationStyle = WindowState == WindowState.Maximized ? UIModalPresentationStyle.FullScreen : UIModalPresentationStyle.FormSheet;

                var top = UIApplication.SharedApplication.KeyWindow.TopMostController();
                opencs = new TaskCompletionSource <bool>();
                top.PresentViewController(Controller, animated: true, completionHandler: () => opencs.SetResult(true));
                await opencs.Task;
                opencs = null;
            }
            if (opening)
            {
                await closedcs.Task;
            }
        }
コード例 #4
0
ファイル: DialogHandler.cs プロジェクト: yaram/Eto
        public virtual void ShowModal()
        {
            session = null;
            Callback.OnShown(Widget, EventArgs.Empty);

            Widget.Closed += HandleClosed;
            if (DisplayMode.HasFlag(DialogDisplayMode.Attached) && Control.ParentWindow != null)
            {
                MacModal.RunSheet(Widget, Control, out session);
            }
            else
            {
                Control.MakeKeyWindow();
                MacModal.Run(Widget, Control, out session);
            }
        }
コード例 #5
0
        public virtual void ShowModal()
        {
            session = null;
            Application.Instance.AsyncInvoke(FireOnShown);             // fire after dialog is shown

            Widget.Closed += HandleClosed;
            if (DisplayMode.HasFlag(DialogDisplayMode.Attached) && Widget.Owner != null)
            {
                MacModal.RunSheet(Widget, Control, Widget.Owner.ToNative(), out session);
            }
            else
            {
                Control.MakeKeyWindow();
                MacModal.Run(Widget, Control, out session);
            }
        }
コード例 #6
0
        public virtual Task ShowModalAsync()
        {
            var tcs = new TaskCompletionSource <bool>();

            session = null;

            Widget.Closed += HandleClosed;
            if (DisplayMode.HasFlag(DialogDisplayMode.Attached) && Widget.Owner != null)
            {
                MacModal.BeginSheet(Widget, Control, Widget.Owner.ToNative(), out session, () => tcs.SetResult(true));
            }
            else
            {
                Control.MakeKeyWindow();
                Application.Instance.AsyncInvoke(() =>
                {
                    Application.Instance.AsyncInvoke(FireOnShown);                     // fire after dialog is shown
                    MacModal.Run(Widget, Control, out session);
                    tcs.SetResult(true);
                });
            }
            return(tcs.Task);
        }
コード例 #7
0
        public void OnResize()
        {
            double scale = 1;

            if (DisplayMode.HasFlag(PageDisplayMode.ActualSize))
            {
                scale = 1;
            }
            else if (DisplayMode.HasFlag(PageDisplayMode.FitPage))
            {
                scale = Math.Min(MainWindow.Current.DisplayArea.ActualWidth / _pageWidths.Max(), MainWindow.Current.DisplayArea.ActualHeight / _pageHeights.Max());
            }
            else if (DisplayMode.HasFlag(PageDisplayMode.FitWidth))
            {
                scale = MainWindow.Current.DisplayArea.ActualWidth / _pageWidths.Max();
            }
            else if (DisplayMode.HasFlag(PageDisplayMode.FitHeight))
            {
                scale = MainWindow.Current.DisplayArea.ActualHeight / _pageHeights.Max();
            }

            this.Zoom(scale);
        }
コード例 #8
0
        public virtual void ShowModal(Control parent)
        {
            session = null;
            if (parent != null && parent.ParentWindow != null)
            {
                var nswindow = parent.ParentWindow.ControlObject as NSWindow;
                if (nswindow != null)
                {
                    Control.ParentWindow = nswindow;
                }
            }
            Callback.OnShown(Widget, EventArgs.Empty);

            Widget.Closed += HandleClosed;
            if (DisplayMode.HasFlag(DialogDisplayMode.Attached))
            {
                MacModal.RunSheet(Widget, Control, out session);
            }
            else
            {
                Control.MakeKeyWindow();
                MacModal.Run(Widget, Control, out session);
            }
        }
コード例 #9
0
        void BuildPrimaryPlane(DisplayMode displayMode)
        {
            Brush brush  = new SolidColorBrush(EmptyColor);
            var   view   = this.InspectView;
            var   matrix = Matrix3D.Identity;

            if (view.Layer != null)
            {
                view = view.Layer;
            }

            var zFightOffset = childIndex * zFightIncrement;
            var zOffset      = ZSpacing + zFightOffset;

            if (view.Transform != null)
            {
                var render = view.Transform;
                matrix = new Matrix3D {
                    M11     = render.M11,
                    M12     = render.M12,
                    M13     = render.M13,
                    M14     = render.M14,
                    M21     = render.M21,
                    M22     = render.M22,
                    M23     = render.M23,
                    M24     = render.M24,
                    M31     = render.M31,
                    M32     = render.M32,
                    M33     = render.M33,
                    M34     = render.M34,
                    OffsetX = render.OffsetX,
                    OffsetY = render.OffsetY,
                    OffsetZ = render.OffsetZ + zOffset
                };
            }

            var size   = new Size(view.Width, view.Height);
            var visual = new DrawingVisual();

            using (var context = visual.RenderOpen()) {
                if (view.BestCapturedImage != null && displayMode.HasFlag(DisplayMode.Content))
                {
                    var bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.StreamSource = new MemoryStream(view.BestCapturedImage);
                    bitmap.EndInit();

                    context.DrawImage(bitmap, new Rect(size));
                }

                if (displayMode.HasFlag(DisplayMode.Frames))
                {
                    context.DrawRectangle(
                        null,
                        new Pen(new SolidColorBrush(Color.FromRgb(0xd3, 0xd3, 0xd3)), 0.5),
                        new Rect(size));
                }
            }

            brush = new ImageBrush {
                ImageSource = new DrawingImage(visual.Drawing)
            };

            var geometry = new MeshGeometry3D()
            {
                Positions = new Point3DCollection {
                    new Point3D(0, 0, 0),
                    new Point3D(0, -size.Height, 0),
                    new Point3D(size.Width, -size.Height, 0),
                    new Point3D(size.Width, 0, 0)
                },
                TextureCoordinates = new PointCollection {
                    new Point(0, 0),
                    new Point(0, 1),
                    new Point(1, 1),
                    new Point(1, 0)
                },
                TriangleIndices = new Int32Collection {
                    0, 1, 2, 0, 2, 3
                },
            };

            var backGeometry = new MeshGeometry3D()
            {
                Positions          = geometry.Positions,
                TextureCoordinates = geometry.TextureCoordinates,
                TriangleIndices    = geometry.TriangleIndices,
                Normals            = new Vector3DCollection {
                    new Vector3D(0, 0, -1),
                    new Vector3D(0, 0, -1),
                    new Vector3D(0, 0, -1),
                    new Vector3D(0, 0, -1)
                }
            };

            material = new DiffuseMaterial(brush)
            {
                Color = BlurColor
            };

            Content = new Model3DGroup()
            {
                Children = new Model3DCollection {
                    new GeometryModel3D {
                        Geometry = geometry,
                        Material = material
                    },
                    new GeometryModel3D {
                        Geometry     = backGeometry,
                        BackMaterial = material,
                    },
                },
                Transform = new ScaleTransform3D {
                    ScaleX = Math.Ceiling(view.Width) / size.Width,
                    ScaleY = -Math.Ceiling(view.Height) / size.Height,
                    ScaleZ = 1
                }
            };

            if ((InspectView.Parent == null && !InspectView.IsFakeRoot) || (InspectView.Parent?.IsFakeRoot ?? false))
            {
                var unitScale = 1.0 / Math.Max(view.Width, view.Height);

                Transform = new Transform3DGroup {
                    Children = new Transform3DCollection {
                        new TranslateTransform3D {
                            OffsetX = -view.Width / 2.0,
                            OffsetY = -view.Height / 2.0,
                            OffsetZ = zOffset
                        },
                        new ScaleTransform3D(unitScale, -unitScale, 1),
                    }
                };
            }
            else
            {
                if (view.Transform != null)
                {
                    Transform = new MatrixTransform3D()
                    {
                        Matrix = matrix
                    };
                }
                else
                {
                    Transform = new TranslateTransform3D(view.X, view.Y, zOffset);
                }
            }
        }