示例#1
0
        Pen CreateNewPen(UBrush b, UStroke s)
        {
            // Link to invalidation of brush, once.
            //  the cache of the pen is stored in the stroke.
            VoidAction inval = delegate { };

            inval = () =>
            {
                s.Invalidate();
                b.changed -= inval;
            };
            b.changed += inval;

            // FIXME advanced features not used!
            Pen ret;

            ret            = new Pen(CreateBrush(b));
            ret.DashCap    = Translate1(s.dashCap);
            ret.EndCap     = Translate2(s.endCap);
            ret.StartCap   = Translate2(s.startCap);
            ret.LineJoin   = Translate(s.lineJoin);
            ret.DashStyle  = Translate(s.dashStyle);
            ret.MiterLimit = s.mitreLimit;
            ret.DashOffset = s.offset;

            // FIXME maybe not right for compatibility with other renderes?
            ret.Alignment = PenAlignment.Center;

            if (s.dashStyle == StrokeType.custom)
            {
                ret.DashPattern = s.custom;
            }

            return(ret);
        }
示例#2
0
        public void MapKey(string key, VoidAction action)
        {
            Guard.ArgumentNotNullNorEmpty("key", key);
            Guard.ArgumentNotNull("action", action);

            MapKey(key, Command.FromAction(action));
        }
        public void MapKey(string key, VoidAction action)
        {
            Guard.ArgumentNotNullNorEmpty("key", key);
            Guard.ArgumentNotNull("action", action);

            MapKey(key, Command.FromAction(action));
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProcessForm"/> class.
        /// </summary>
        /// <param name="stopDelegate">The stop delegate.</param>
        /// <param name="startDelegate">The start delegate.</param>
        /// <param name="startArguments">The start arguments.</param>
        public ProcessForm(
            VoidAction stopDelegate,
            VoidStringArgsAction startDelegate,
            string[] startArguments
            )
        {
            //this.allo
            //this.serviceHost = serviceHost;
            this.stopDelegate = stopDelegate;
            this.startDelegate = startDelegate;
            this.startArguments = startArguments;

            InitializeComponent();

            setupPropertyGrid.SelectedObject =
                AppDomain.CurrentDomain.SetupInformation;

            //SetProcessControlButtons(true);
            try
            {

                Console.SetOut(new TextControlTextWriter(this.logRichTextBox));
                //Trace.Listeners.Add(new ConsoleTraceListener(false));
            }
            catch (SecurityException ex)
            {
                ShowErrorMessage(MessagesResource.CannotLogToTestConsole + Environment.NewLine +
                    ex.ToString());
            }
        }
示例#5
0
 public void StartContinuingAction(string name, float time, VoidAction action)
 {
     progress   = 0f;
     goal       = time;
     actionName = name;
     StartCoroutine(StartContinuingAction_IE(action));
 }
示例#6
0
        public override void WriteLine(string value)
        {
            VoidAction action = delegate
            {
                if (!string.IsNullOrEmpty(searchKey) && !value.Contains(searchKey))
                {
                    return;
                }
                if (tbox.Lines.Length > 200)
                {
                    tbox.Clear();
                }
                tbox.AppendText(value + "\r\n");
                if (value.Contains("MessageBox|"))
                {
                    MessageBox.Show(value.Replace("MessageBox|", ""));
                }
            };

            try
            {
                tbox.BeginInvoke(action);
            }
            catch (Exception)
            {
            }
        }
示例#7
0
            public override void Write(string str)
            {
                CheckFull();
                VoidAction action = () => _txtBox.AppendText(str);

                _txtBox.BeginInvoke(action);
            }
示例#8
0
            public override void Write(string fmt, params object[] args)
            {
                CheckFull();
                VoidAction action = () => _txtBox.AppendText(string.Format(fmt, args));

                _txtBox.BeginInvoke(action);
            }
        public virtual void Run(VoidAction tickCallback)
        {
            m_tickCallback = tickCallback;

            while (!IsDone)
                m_tickCallback();
        }        
示例#10
0
            public override void Write(char value)
            {
                CheckFull();
                VoidAction action = () => _txtBox.AppendText(value.ToString());

                _txtBox.BeginInvoke(action);
            }
示例#11
0
        private void TestTree(
            string label,
            IRangeList tree,
            IEnumerable <Op> sequence,
            VoidAction action)
        {
            try
            {
                BuildTree(tree, sequence);
            }
            catch (Exception exception)
            {
                Console.WriteLine("{0} [setup]: Unexpected exception occurred: {1}", label, exception);
                throw new UnitTestFailureException(label, exception);
            }

            try
            {
                action();
            }
            catch (Exception exception)
            {
                Console.WriteLine("{0} [action]: Unexpected exception occurred: {1}", label, exception);
                throw new UnitTestFailureException(label, exception);
            }

            ValidateRanges(((INonInvasiveRange2MapInspection)tree).GetRanges());
        }
示例#12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProcessForm"/> class.
        /// </summary>
        /// <param name="stopDelegate">The StopInternal delegate.</param>
        /// <param name="startDelegate">The StartInternal delegate.</param>
        /// <param name="startArguments">The StartInternal arguments.</param>
        public ProcessForm(
            VoidAction stopDelegate,
            VoidStringArgsAction startDelegate,
            string[] startArguments
            )
        {
            //this.allo
            //this.serviceHost = serviceHost;
            this.stopDelegate = stopDelegate;
            this.startDelegate = startDelegate;
            this.startArguments = startArguments;

            InitializeComponent();

            setupPropertyGrid.SelectedObject =
                AppDomain.CurrentDomain.SetupInformation;

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            //SetProcessControlButtons(true);
            try
            {
                logTextWriter = new TextControlTextWriter(outputListView,
                                                          Settings.Default.DescriptionRegex);
                Console.SetOut(logTextWriter);
                //Trace.Listeners.Add(new ConsoleTraceListener(false));
            }
            catch (SecurityException ex)
            {
                ShowErrorMessage(MessagesResource.CannotLogToTestConsole + Environment.NewLine +
                                 ex);
            }
        }
示例#13
0
        public override void Run(VoidAction tickCallback)
        {
            // 59.75 is sort of compensation
            long ticksPerFrame = (int)Math.Round(MyGameTimer.Frequency / 59.75f);
            long targetTicks   = 0;

            MyLog.Default.WriteLine("Timer Frequency: " + MyGameTimer.Frequency);
            MyLog.Default.WriteLine("Ticks per frame: " + ticksPerFrame);

            ManualResetEventSlim waiter = new ManualResetEventSlim(false, 0);

            MyTimer.TimerEventHandler handler = new MyTimer.TimerEventHandler((a, b, c, d, e) =>
            {
                waiter.Set();
            });


            base.Run(delegate
            {
                using (Stats.Generic.Measure("WaitForUpdate"))
                {
                    var currentTicks = m_gameTimer.ElapsedTicks;

                    // Wait for correct frame start
                    targetTicks += ticksPerFrame;
                    if (currentTicks > targetTicks + ticksPerFrame * 5)
                    {
                        // We're more behind than 5 frames, don't try to catch up
                        targetTicks = currentTicks;
                    }
                    else
                    {
                        // For until correct tick comes
                        if (MyFakes.ENABLE_UPDATE_WAIT)
                        {
                            var remaining = MyTimeSpan.FromTicks(targetTicks - currentTicks);
                            int waitMs    = (int)(remaining.Miliseconds - 0.1); // To handle up to 0.1ms inaccuracy of timer
                            if (waitMs > 0)
                            {
                                waiter.Reset();
                                MyTimer.StartOneShot(waitMs, handler);
                                waiter.Wait(17); // Never wait more than 17ms
                                //Debug.Assert(MyPerformanceCounter.ElapsedTicks < targetTicks);
                                //VRageRender.MyRenderStats.Write("WaitRemaining", (float)MyPerformanceCounter.TicksToMs(targetTicks - MyPerformanceCounter.ElapsedTicks), VRageRender.MyStatTypeEnum.MinMaxAvg, 300, 3);
                            }
                        }
                        while (m_gameTimer.ElapsedTicks < targetTicks)
                        {
                            ;
                        }
                    }
                }

                //UpdateInternal();
                tickCallback();

                ProfilerShort.Commit();
            });
        }
示例#14
0
        public void VoidNoArgDelegate()
        {
            testVoidActionExecuted = false;
            VoidAction voidAction = MyAction;

            voidAction();
            Assert.IsTrue(testVoidActionExecuted);
        }
 private void InAssembly(VoidAction<ITypeOptions> create)
 {
     AssemblyBuilder.CreateNewDll(with =>
     {
         with.Name(AssemblyName);
         create(with.Type);
     });
 }
示例#16
0
        /// <summary>
        /// Runs the specified action in a thread.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <param name="taskName">Name of the task.</param>
        public static void Run(VoidAction action, string taskName = "SharpDXTask")
        {
#if W8CORE
            System.Threading.Tasks.Task.Factory.StartNew(() => action(), System.Threading.Tasks.TaskCreationOptions.LongRunning);
#else
            var thread = new System.Threading.Thread(() => action()) { IsBackground = true, Name = taskName };
            thread.Start();
#endif
        }
示例#17
0
        public override void WriteLine(string value)
        {
            VoidAction action = delegate
            {
                _listBox.Items.Insert(0, string.Format("[{0:HH:mm:ss}]{1}", DateTime.Now, value));
            };

            _listBox.BeginInvoke(action);
        }
示例#18
0
        public override bool Compile()
        {
            if (base.Compile())
            {
                CompiledDelegate = Expression.Lambda <VoidAction>(ExpressionForThisRule).Compile();
            }

            return(CompiledDelegate != null);
        }
示例#19
0
        public virtual void Run(VoidAction tickCallback)
        {
            m_tickCallback = tickCallback;

            while (!IsDone)
            {
                m_tickCallback();
            }
        }
        public override void WriteLine(string value)
        {
            VoidAction action = delegate
            {
                _textBox.AppendText(value);
            };

            _textBox.BeginInvoke(action);
        }
示例#21
0
 private void DontCare(VoidAction action)
 {
     try
     {
         action();
     }
     catch
     {
     }
 }
示例#22
0
        public override void Run(VoidAction tickCallback)
        {
            // 59.75 is sort of compensation
            long ticksPerFrame = (int)Math.Round(MyGameTimer.Frequency / 59.75f);
            long targetTicks = 0;

            MyLog.Default.WriteLine("Timer Frequency: " + MyGameTimer.Frequency);
            MyLog.Default.WriteLine("Ticks per frame: " + ticksPerFrame);

            ManualResetEventSlim waiter = new ManualResetEventSlim(false, 0);
            MyTimer.TimerEventHandler handler = new MyTimer.TimerEventHandler((a, b, c, d, e) =>
            {
                waiter.Set();
            });


            base.Run(delegate
            {
                using (Stats.Generic.Measure("WaitForUpdate"))
                {
                    var currentTicks = m_gameTimer.ElapsedTicks;

                    // Wait for correct frame start
                    targetTicks += ticksPerFrame;
                    if (currentTicks > targetTicks + ticksPerFrame * 5)
                    {
                        // We're more behind than 5 frames, don't try to catch up
                        targetTicks = currentTicks;
                    }
                    else
                    {
                        // For until correct tick comes
                        if (MyFakes.ENABLE_UPDATE_WAIT)
                        {
                            var remaining = MyTimeSpan.FromTicks(targetTicks - currentTicks);
                            int waitMs = (int)(remaining.Miliseconds - 0.1); // To handle up to 0.1ms inaccuracy of timer
                            if (waitMs > 0)
                            {
                                waiter.Reset();
                                MyTimer.StartOneShot(waitMs, handler);
                                waiter.Wait(17); // Never wait more than 17ms
                                //Debug.Assert(MyPerformanceCounter.ElapsedTicks < targetTicks);
                                //VRageRender.MyRenderStats.Write("WaitRemaining", (float)MyPerformanceCounter.TicksToMs(targetTicks - MyPerformanceCounter.ElapsedTicks), VRageRender.MyStatTypeEnum.MinMaxAvg, 300, 3);
                            }
                        }
                        while (m_gameTimer.ElapsedTicks < targetTicks) ;
                    }
                }

                //UpdateInternal();
                tickCallback();

                ProfilerShort.Commit();
            });
        }
示例#23
0
        public override void WriteLine(string value)
        {
            VoidAction action = delegate
            {
                List <string> temp = new List <string>(lstBox.Lines);
                temp.Insert(0, string.Format("[{0:HH:mm:ss}]{1}", DateTime.Now, value));
                lstBox.Lines = temp.ToArray();
            };

            lstBox.BeginInvoke(action);
        }
示例#24
0
        public ClickableControl(VoidAction primary, VoidAction secondary = null)
        {
            Debug.Assert(primary != null, "At least one action must be given to a clickable control");

            PrimaryAction = primary;

            if (secondary == null)
                SecondaryAction = () => { };
            else
                SecondaryAction = secondary;
        }
示例#25
0
        public ConditionalStatement Else(VoidAction<List<IStatement>> code)
        {
            var blockStatements = new List<IStatement>();
            code(blockStatements);

            var elseBranch = new BlockStatement();
            elseBranch.Statements = blockStatements;

            ifStatement.FalseBranch = elseBranch;
            return ifStatement;
        }
示例#26
0
        public override void Run(object windowContext, VoidAction initCallback, VoidAction tickCallback)
        {
            // If window context is null under WinRT, then this is a non-XAML application
            IsBlockingRun = true;

            // Initialize the window
            Window.Initialize(windowContext);

            // Rendering to CoreWindow
            gameWindowWP8.RunDrawingSurfaceBackground(initCallback, tickCallback);
        }
示例#27
0
        public override void Write(string value)
        {
            VoidAction action = delegate
            {
                //lstBox.Items.Insert(0, string.Format("[{0:HH:mm:ss}]{1}", DateTime.Now, value));
                lstBox.TopIndex = lstBox.Items.Count - 1;
                lstBox.Items.Add(value);
            };

            lstBox.BeginInvoke(action);
        }
示例#28
0
 public static void Execute <TIgnoreException>(VoidAction operation)
     where TIgnoreException : Exception
 {
     try
     {
         operation();
     }
     catch (TIgnoreException)
     {
     }
 }
示例#29
0
     private void DontCare( VoidAction action )
     {
         try
         {
             action();
         }
         catch
         {
             
         }
 }
示例#30
0
        /// <summary>
        /// Runs the specified action in a thread.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <param name="taskName">Name of the task.</param>
        public static void Run(VoidAction action, string taskName = "SharpDXTask")
        {
#if W8CORE
            System.Threading.Tasks.Task.Factory.StartNew(() => action(), System.Threading.Tasks.TaskCreationOptions.LongRunning);
#else
            var thread = new System.Threading.Thread(() => action())
            {
                IsBackground = true, Name = taskName
            };
            thread.Start();
#endif
        }
示例#31
0
        public override void WriteLine(string value)
        {
            VoidAction action = delegate
            {
                if (logBox.Text.Count() > 10000)
                {
                    this.logBox.Text = "";
                }
                logBox.Text += (string.Format("[{0:yyyy-MM-dd HH:mm:ss.fff}]{1}", DateTime.Now, value) + "\r\n");
            };

            logBox.BeginInvoke(action);
        }
示例#32
0
        public override void Run(VoidAction tickCallback)
        {
            base.Run(delegate
            {
                using (StatGroup.Measure(StatName))
                {
                    m_waiter.Wait();
                }

                //UpdateInternal();
                tickCallback();
            });
        }
示例#33
0
        public override void Write(char value)
        {
            //base.Write(value);//still output to Console
            VoidAction action = delegate {
                txtBox.AppendText(value.ToString());
                //if(txtBox.Visibility == Visibility.Visible)
                //{
                //    txtBox.ScrollToEnd();
                //}
            };

            txtBox.Dispatcher.BeginInvoke(action);
        }
示例#34
0
        public override void Run(VoidAction tickCallback)
        {
            base.Run(delegate
            {
                using (StatGroup.Measure(StatName))
                {
                    m_waiter.Wait();
                }

                //UpdateInternal();
                tickCallback();
            });
        }
示例#35
0
        public override void Run(VoidAction tickCallback)
        {
            long targetTicks = 0;

            ManualResetEventSlim waiter = new ManualResetEventSlim(false, 0);

            MyTimer.TimerEventHandler handler = new MyTimer.TimerEventHandler((a, b, c, d, e) =>
            {
                waiter.Set();
            });

            base.Run(delegate
            {
                using (StatGroup.Measure(StatName))
                {
                    var currentTicks = m_gameTimer.ElapsedTicks;

                    // Wait for correct frame start
                    targetTicks += TickPerFrame;
                    if (currentTicks > targetTicks + TickPerFrame * 5)
                    {
                        // We're more behind than 5 frames, don't try to catch up
                        targetTicks = currentTicks;
                    }
                    else
                    {
                        // For until correct tick comes
                        if (EnableUpdateWait)
                        {
                            var remaining = MyTimeSpan.FromTicks(targetTicks - currentTicks);
                            int waitMs    = (int)(remaining.Miliseconds - 0.1); // To handle up to 0.1ms inaccuracy of timer
                            if (waitMs > 0)
                            {
                                waiter.Reset();
                                MyTimer.StartOneShot(waitMs, handler);
                                waiter.Wait(17); // Never wait more than 17ms
                                //Debug.Assert(MyPerformanceCounter.ElapsedTicks < targetTicks);
                                //VRageRender.MyRenderStats.Write("WaitRemaining", (float)MyPerformanceCounter.TicksToMs(targetTicks - MyPerformanceCounter.ElapsedTicks), VRageRender.MyStatTypeEnum.MinMaxAvg, 300, 3);
                            }
                        }
                        while (m_gameTimer.ElapsedTicks < targetTicks)
                        {
                            ;
                        }
                    }
                }

                //UpdateInternal();
                tickCallback();
            });
        }
示例#36
0
    public IEnumerator StartContinuingAction_IE(VoidAction action)
    {
        while (progress < goal)
        {
            Debug.Log("Increase Progress");
            ActionInProgress = true;
            yield return(new WaitForSeconds(0.03f));

            progress += 0.03f;
        }
        ActionInProgress = false;
        action();
        Debug.Log("coroutine ends");
    }
        public IExpression WithBody(VoidAction<ICodeBuilder> code)
        {
            method.Type = delegateType;
            method.CallingConvention = CallingConvention.HasThis;
            method.ReturnType = returnTypeReference;

            var codeBuilder = new CodeBuilder(host, method.Parameters);
            code(codeBuilder);

            var body = new BlockStatement();
            foreach (var statement in codeBuilder.Statements) body.Statements.Add(statement);
            method.Body = body;

            return method;
        }
示例#38
0
        public override void Write(string value)
        {
            VoidAction action = delegate
            {
                tbox.AppendText(value);
            };

            try
            {
                tbox.BeginInvoke(action);
            }
            catch (Exception)
            {
            }
        }
示例#39
0
    IEnumerator MovePanel(Vector2 endPos, VoidAction action)
    {
        Vector3 direction = ((Vector3)endPos - panel.transform.position).normalized;

        while (Vector2.Distance(panel.transform.position, endPos) > speed * Time.deltaTime)
        {
            panel.transform.position += direction * speed * Time.deltaTime;
            yield return(null);
        }

        if (action != null)
        {
            action();
        }
    }
示例#40
0
 /// <summary>
 /// Subscribe the specified key with the given method.
 /// </summary>
 /// <param name="key">Key to subscribe to</param>
 /// <param name="d">The void action to run when published</param>
 public static void Subscribe(string key, VoidAction d)
 {
     //If the subscription already contains the key,
     //add this delegate to the existing delegate under the given key
     if (voidSubscriptions.ContainsKey(key))
     {
         //Add delegate to existing delegate
         voidSubscriptions[key] += d;
     }
     else
     {
         //Create a new entry in the subscription dictonary
         voidSubscriptions.Add(key, d);
     }
 }
示例#41
0
	/// <summary>
	/// Subscribe the specified key with the given method.
	/// </summary>
	/// <param name="key">Key to subscribe to</param>
	/// <param name="d">The void action to run when published</param>
	public static void Subscribe(string key, VoidAction d)
	{
		//If the subscription already contains the key,
		//add this delegate to the existing delegate under the given key
		if(voidSubscriptions.ContainsKey(key))
		{
			//Add delegate to existing delegate
			voidSubscriptions[key] += d;
		}
		else
		{
			//Create a new entry in the subscription dictonary
			voidSubscriptions.Add(key, d);
		}
	}
示例#42
0
 static void *WithExceptionsCatched(VoidAction action)
 {
     try
     {
         action();
         return(ToPointer(new InvokationResult()));
     }
     catch (TargetInvocationException e)
     {
         return(ToPointer(new InvokationResult(e.InnerException, true)));
     }
     catch (Exception e)
     {
         return(ToPointer(new InvokationResult(e, true)));
     }
 }
示例#43
0
        public override void Run(VoidAction tickCallback)
        {
            long targetTicks = 0;
            
            ManualResetEventSlim waiter = new ManualResetEventSlim(false, 0);
            MyTimer.TimerEventHandler handler = new MyTimer.TimerEventHandler((a, b, c, d, e) =>
            {
                waiter.Set();
            });

            base.Run(delegate
            {
                using (StatGroup.Measure(StatName))
                {
                    var currentTicks = m_gameTimer.ElapsedTicks;

                    // Wait for correct frame start
                    targetTicks += TickPerFrame;
                    if (currentTicks > targetTicks + TickPerFrame * 5)
                    {
                        // We're more behind than 5 frames, don't try to catch up
                        targetTicks = currentTicks;
                    }
                    else
                    {
                        // For until correct tick comes
                        if (EnableUpdateWait)
                        {
                            var remaining = MyTimeSpan.FromTicks(targetTicks - currentTicks);
                            int waitMs = (int)(remaining.Miliseconds - 0.1); // To handle up to 0.1ms inaccuracy of timer
                            if (waitMs > 0)
                            {
                                waiter.Reset();
                                MyTimer.StartOneShot(waitMs, handler);
                                waiter.Wait(17); // Never wait more than 17ms
                                //Debug.Assert(MyPerformanceCounter.ElapsedTicks < targetTicks);
                                //VRageRender.MyRenderStats.Write("WaitRemaining", (float)MyPerformanceCounter.TicksToMs(targetTicks - MyPerformanceCounter.ElapsedTicks), VRageRender.MyStatTypeEnum.MinMaxAvg, 300, 3);
                            }
                        }
                        while (m_gameTimer.ElapsedTicks < targetTicks) ;
                    }
                }

                //UpdateInternal();
                tickCallback();
            });
        }
示例#44
0
        public Notification(string message, DrawingRectangleF screenArea, NotificationType type = NotificationType.Message)
            : base()
        {
            System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(message), "Notification message should not be null or empty.");
            this.IsVisible = true;
            this.IsActive = true;
            this.IsRounded = false;
            this.LayoutOption = LayoutType.Vertical;
            this.ResizeOption = ResizeOptions.WrapChildren;
            this.HorizontalAlignment = Controls.HorizontalAlignment.Center;
            this.VerticalAlignment = Controls.VerticalAlignment.Center;
            this.DrawBackground = true;
            this.DrawBorder = true;
            _buttonAction = () => { this.Close(); };

            Position = screenArea.Position;
            Size = screenArea.Size;

            var label = new Label() {
                Text = message,
                VerticalAlignment = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Center
            };
            label.Size = Size;
            AddControl(label);

            switch (type) {
                case NotificationType.Message:
                    var button = new Button(_buttonAction) {
                        Text = "Ok",
                        Size = new Vector2(this.Width / 4f, DEFAULT_BUTTON_HEIGHT),
                        VerticalAlignment = VerticalAlignment.Top,
                        HorizontalAlignment = HorizontalAlignment.Center
                    };
                    AddControl(button);
                    break;

                case NotificationType.Temporary:
                    this.Expires = true;
                    this.Duration = Notification.TemporaryNotificationDuration;
                    break;
            }
        }
示例#45
0
        public ListTextWriter(ListBox box, long lastCount = 3000)
        {
            _listBox = box;
            System.Threading.Tasks.Task.Run(() =>
            {
                while (true)
                {
                    if (_listBox.Items.Count >= lastCount)
                    {
                        VoidAction action = delegate
                        {
                            _listBox.Items.Clear();
                        };
                        _listBox.BeginInvoke(action);
                    }

                    System.Threading.Thread.Sleep(3000);
                }
            });
        }
示例#46
0
    public static void startJob(string key, VoidAction d, float time)
    {
        lock (dic) {
            if (dic.ContainsKey(key))
            {
                dic.Remove(key);
            }
            else if (dic2.ContainsKey(key))
            {
                dic2[key].cancel = true;
                dic2.Remove(key);
            }
            JobAction jobAction = new JobAction();
            jobAction.key    = key;
            jobAction.d      = d;
            jobAction.time   = time;
            jobAction.cancel = false;

            dic.Add(key, jobAction);
        }
    }
示例#47
0
        public override void Run(object windowContext, VoidAction initCallback, VoidAction tickCallback)
        {
            // Initialize the window
            Window.Initialize(windowContext);

            // Register on Activated 
            Window.Activated += OnActivated;
            Window.Deactivated += OnDeactivated;

            // Initialize the init callback
            initCallback();

            // Run the rendering loop
            try
            {
                RenderLoop.Run((Control)Window.NativeWindow, new RenderLoop.RenderCallback(tickCallback));
            } 
            finally
            {
                OnExiting(this, EventArgs.Empty);
            }
        }
        public override void Run(object windowContext, VoidAction initCallback, VoidAction tickCallback)
        {
            // If window context is null under WinRT, then this is a non-XAML application
            IsBlockingRun = windowContext == null;

            // Initialize the window
            Window.Initialize(windowContext);

            this.tickCallback = tickCallback;

            if (windowContext == null)
            {
                // Rendering to CoreWindow
                gameWindowWinRT.RunCoreWindow(initCallback, tickCallback);
            }
            else
            {
                // Rendering to SwapChainBackgroundPanel
                initCallback();
                CompositionTarget.Rendering += CompositionTarget_Rendering;
            }
        }
示例#49
0
 public Command(VoidAction action)
 {
     Guard.ArgumentNotNull("action", action);
     _action = action;
 }
示例#50
0
        public static ICommand FromAction(VoidAction action)
        {
            Guard.ArgumentNotNull("action", action);

            return new Command(action);
        }
示例#51
0
 public IModule CreateNewDll(VoidAction<IAssemblyConstructionOptions> with)
 {
     with(this);
     return CreateNewDll(model.Name);
 }
示例#52
0
 public abstract void Run(object windowContext, VoidAction initCallback, VoidAction tickCallback);
示例#53
0
        public override void Run(object windowContext, VoidAction initCallback, VoidAction tickCallback)
        {
            // Initialize the window
            Window.Initialize(windowContext);

            // Initialize the init callback
            initCallback();

            // Run the rendering loop
            RenderLoop.Run((Control)Window.NativeWindow, new RenderLoop.RenderCallback(tickCallback));
        }
示例#54
0
        public void UnwrapsTargetInvocationException()
        {
            if (SystemUtils.MonoRuntime)
            {
            #if DEBUG
                // TODO (EE): find solution for Mono
                return;
            #endif
            }

            MethodInfo mi = new VoidAction(ThrowDummyException).Method;
            try
            {
                try
                {
                    mi.Invoke(null, null);
                    Assert.Fail();
                }
                catch (TargetInvocationException tie)
                {
                    //                    Console.WriteLine(tie);
                    throw ReflectionUtils.UnwrapTargetInvocationException(tie);
                }
                Assert.Fail();
            }
            catch (DummyException e)
            {
                //                Console.WriteLine(e);
                string[] stackFrames = e.StackTrace.Split('\n');
            #if !MONO
                // TODO: mono includes the invoke() call in inner stackframe does not include the outer stackframes - either remove or document it
                string firstFrameMethodName = mi.DeclaringType.FullName + "." + mi.Name;
                AssertStringContains(firstFrameMethodName, stackFrames[0]);
                string lastFrameMethodName = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name;
                AssertStringContains(lastFrameMethodName, stackFrames[stackFrames.Length - 1]);

            #endif
            }
        }
示例#55
0
	/// <summary>
	/// Subscribe to an event in the pub sub dictionaries. This will attach
	/// to the dictionary containing only VoidActions, which do not return values
	/// on execution.
	/// </summary>
	/// <param name="key">Name of Value in Dictionary</param>
	/// <param name="sub">Subscription of methods to Key</param>
	public void Subscribe(string key, VoidAction sub)
	{
		EventDispatcher.Subscribe(key, sub);
	}
示例#56
0
        public void RunCoreWindow(VoidAction initCallback, VoidAction tickCallback)
        {
            this.initCallback = initCallback;
            this.tickCallback = tickCallback;

            CoreApplication.Run(this);
        }
		public override IAsyncResult BeginStop(object state, AsyncCallback callback)
		{
			// Very raw for a moment, just proof of concept (SD)
			VoidAction joinDelegate = new VoidAction(Stop);
			
			return joinDelegate.BeginInvoke
				(
				new AsyncCallback
				(
				callback
				),
				new Descriptor(Name, Description)
				);
		}
示例#58
0
 public Button(VoidAction leftClick, VoidAction rightClick = null)
     : base(leftClick, rightClick)
 {
 }
示例#59
0
        public void MapNoKey(VoidAction action)
        {
            Guard.ArgumentNotNull("action", action);

            MapKey(NoKey, action);
        }
示例#60
0
        public void RunDrawingSurfaceBackground(VoidAction initCallback, VoidAction tickCallback)
        {
            this.initCallback = initCallback;
            this.tickCallback = tickCallback;

            // Set the background to this 
            drawingSurfaceBackgroundGrid.SetBackgroundContentProvider(this);
        }