コード例 #1
0
        protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
        {
            if (X == null || Y == null)
            {
                return(Completion.Exception(Properties.Language.NullException, this));
            }
            var c = X.Execute(enviroment);

            if (!c.IsValue)
            {
                return(c);
            }
            if (!TypeConverters.IsNumber(c.ReturnValue))
            {
                return(Completion.Exception(Properties.Language.ValueNotNumberException, X));
            }
            double d = TypeConverters.GetValue <double>(c.ReturnValue);

            var e = X.Execute(enviroment);

            if (!e.IsValue)
            {
                return(e);
            }
            if (!TypeConverters.IsNumber(e.ReturnValue))
            {
                return(Completion.Exception(Properties.Language.ValueNotNumberException, Y));
            }
            double f = TypeConverters.GetValue <double>(e.ReturnValue);

            DrawWindow wnd = CanvasEnvironment.GetCanvas(enviroment);

            wnd.LineTo(d, f);
            return(Completion.Void);
        }
コード例 #2
0
        protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
        {
            if (Step == null || Angle == null || XRadius == null || YRadius == null)
            {
                return(Completion.Exception(Properties.Language.NullException, this));
            }

            var c = Step.Execute(enviroment);

            if (!c.IsValue)
            {
                return(c);
            }
            if (!TypeConverters.IsNumber(c.ReturnValue))
            {
                return(Completion.Exception(Properties.Language.ValueNotNumberException, Step));
            }
            double step = TypeConverters.GetValue <double>(c.ReturnValue);

            var d = Angle.Execute(enviroment);

            if (!d.IsValue)
            {
                return(d);
            }
            if (!TypeConverters.IsNumber(d.ReturnValue))
            {
                return(Completion.Exception(Properties.Language.ValueNotNumberException, Angle));
            }
            double angle = TypeConverters.GetValue <double>(d.ReturnValue);

            var e = XRadius.Execute(enviroment);

            if (!e.IsValue)
            {
                return(e);
            }
            if (!TypeConverters.IsNumber(e.ReturnValue))
            {
                return(Completion.Exception(Properties.Language.ValueNotNumberException, XRadius));
            }
            double x = TypeConverters.GetValue <double>(e.ReturnValue);

            var f = YRadius.Execute(enviroment);

            if (!f.IsValue)
            {
                return(f);
            }
            if (!TypeConverters.IsNumber(f.ReturnValue))
            {
                return(Completion.Exception(Properties.Language.ValueNotNumberException, YRadius));
            }
            double     y   = TypeConverters.GetValue <double>(f.ReturnValue);
            DrawWindow wnd = CanvasEnvironment.GetCanvas(enviroment);

            wnd.Arc(step, angle, x, y);
            return(Completion.Void);
        }
コード例 #3
0
        protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
        {
            DrawWindow wnd = CanvasEnvironment.GetCanvas(enviroment);

            object v = wnd.Fill;

            return(new Completion(v));
        }
コード例 #4
0
        public Completion Assign(ExecutionEnvironment environment, object value)
        {
            if (!(value is Color))
            {
                return(Completion.Exception(Properties.Language.NotColorException, this));
            }
            DrawWindow wnd = CanvasEnvironment.GetCanvas(environment);

            wnd.Fill = (Color)value;
            return(new Completion(value));
        }
コード例 #5
0
        public Completion Assign(ExecutionEnvironment environment, object value)
        {
            if (!TypeConverters.IsNumber(value))
            {
                return(Completion.Exception(Properties.Language.ValueNotNumberException, this));
            }
            DrawWindow wnd = CanvasEnvironment.GetCanvas(environment);

            wnd.Thickness = TypeConverters.GetValue <double>(value);
            return(new Completion(value));
        }
コード例 #6
0
        protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
        {
            DrawWindow wnd = CanvasEnvironment.GetCanvas(enviroment);
            MethodInfo m   = wnd.GetType().GetMethod(Func);

            if (m == null)
            {
                return(Completion.Exception("No " + Func + " function in canvas", this));
            }
            m.Invoke(wnd, null);
            return(Completion.Void);
        }
コード例 #7
0
        protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
        {
            if (Text == null)
            {
                return(Completion.Exception(Properties.Language.NullException, this));
            }
            var c = Text.Execute(enviroment);

            if (!c.IsValue)
            {
                return(c);
            }
            string     d   = c.ReturnValue + "";
            DrawWindow wnd = CanvasEnvironment.GetCanvas(enviroment);

            wnd.Text(d);
            return(Completion.Void);
        }
コード例 #8
0
        protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
        {
            if (Step == null)
            {
                return(Completion.Exception(Properties.Language.NullException, this));
            }
            var c = Step.Execute(enviroment);

            if (!c.IsValue)
            {
                return(c);
            }
            if (!TypeConverters.IsNumber(c.ReturnValue))
            {
                return(Completion.Exception(Properties.Language.ValueNotNumberException, Step));
            }
            double     d   = TypeConverters.GetValue <double>(c.ReturnValue);
            DrawWindow wnd = CanvasEnvironment.GetCanvas(enviroment);

            wnd.Turn(d);
            return(Completion.Void);
        }
コード例 #9
0
        protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
        {
            if (FontFamily == null)
            {
                return(Completion.Exception(Properties.Language.NullException, this));
            }
            Typeface face = null;

            foreach (var f in Fonts.SystemTypefaces)
            {
                if (f.FontFamily.Equals(FontFamily) && f.Style.Equals(Style) && f.Weight.Equals(Weight))
                {
                    face = f;
                    break;
                }
            }
            if (face == null)
            {
                foreach (var f in Fonts.SystemTypefaces)
                {
                    if (f.FontFamily.Equals(FontFamily) && f.Style.Equals(Style))
                    {
                        face = f;
                        break;
                    }
                }
            }
            if (face == null)
            {
                face = new Typeface(FontFamily);
            }
            DrawWindow wnd = CanvasEnvironment.GetCanvas(enviroment);

            wnd.Font = face;
            return(Completion.Void);
        }
コード例 #10
0
        public static DrawWindow GetCanvas(ExecutionEnvironment environment)
        {
            DrawWindow canvas = null;

            if (!environment.HasValue(CanvasName))
            {
                ExecutionEnvironment b = environment.GetBaseEnvironment();
                Application.Current.Dispatcher.Invoke(() =>
                {
                    canvas = new DrawWindow();
                    if (Application.Current.MainWindow != null)
                    {
                        canvas.Owner = Application.Current.MainWindow;
                    }
                    canvas.Show();
                });
                b.RegisterValue(CanvasName, canvas);
            }
            else
            {
                canvas = environment.GetValue(CanvasName) as DrawWindow;
            }
            return(canvas);
        }