예제 #1
0
		Control StartStopButton(ProgressBar bar)
		{
			var control = new Button { Text = "Start Timer" };
			control.Click += delegate
			{
				if (timer == null)
				{
					timer = new UITimer { Interval = 0.5 };
					timer.Elapsed += delegate
					{
						if (bar.Value < bar.MaxValue)
							bar.Value += 50;
						else
							bar.Value = bar.MinValue;
					};
					timer.Start();
					control.Text = "Stop Timer";
				}
				else
				{
					timer.Stop();
					timer.Dispose();
					timer = null;
					control.Text = "Start Timer";
				}
			};
			return control;
		}
예제 #2
0
		public PreviewEditorView(Control editor, Func<string> getCode)
		{
			Editor = editor;
			this.getCode = getCode;

			Orientation = Orientation.Vertical;
			FixedPanel = SplitterFixedPanel.None;
			RelativePosition = 0.4;

			previewPanel = new Panel();
			errorPanel = new Panel { Padding = new Padding(5), Visible = false, BackgroundColor = new Color(Colors.Red, .4f) };

			Panel1 = new StackLayout
			{
				HorizontalContentAlignment = HorizontalAlignment.Stretch,
				Items =
				{
					new StackLayoutItem(previewPanel, expand: true),
					errorPanel
				}
			};
			Panel2 = editor;

			timer = new UITimer { Interval = RefreshTime };
			timer.Elapsed += Timer_Elapsed;
		}
예제 #3
0
 /// <summary>
 /// Perform the initial refresh on load
 /// </summary>
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     _refreshTimer = new UITimer();
     _refreshTimer.Interval = RefreshInterval.TotalSeconds;
     _refreshTimer.Elapsed += _refresh;
     _refreshTimer.Start();
     _refresh(null, null);
 }
예제 #4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var database = BACnetSession.Current.GetProcess<NetworkDatabase>();
            this._devices = new DeviceTreeStore(Application.Instance);
            this._devicesSubscription = database.Subscribe(new DescriptorQuery(objectType: 8), this._devices);
            _tree.DataStore = this._devices;

            _refreshTimer = new UITimer();
            _refreshTimer.Interval = .5;
            _refreshTimer.Elapsed += _refreshTimerElapsed;
            _refreshTimer.Start();
        }
예제 #5
0
		public PreviewEditorView(Control editor, string mainAssembly, IEnumerable<string> references, Func<string> getCode)
		{
			//Size = new Size (200, 200);
			Editor = editor;
			MainAssemblyPath = mainAssembly;
			this.getCode = getCode;

			if (EnableAppDomains)
				designPanel = new AppDomainDesignHost();
			else
				designPanel = new InProcessDesignPanel();

			designPanel.MainAssembly = mainAssembly;
			designPanel.References = references;

			designPanel.ControlCreated = () => FinishProcessing(null);
			designPanel.Error = FinishProcessing;

			designPanelHolder = new Panel();
			designPanelHolder.Content = designPanel.GetContainer();

			designPanel.ContainerChanged = () => designPanelHolder.Content = designPanel.GetContainer();

			Orientation = Orientation.Vertical;
			FixedPanel = SplitterFixedPanel.None;
			RelativePosition = lastPosition;

			errorPanel = new Panel { Padding = new Padding(5), Visible = false, BackgroundColor = new Color(Colors.Red, .4f) };

			Panel1 = new StackLayout
			{
				HorizontalContentAlignment = HorizontalAlignment.Stretch,
				Items =
				{
					new StackLayoutItem(designPanelHolder, expand: true),
					errorPanel
				}
			};
			Panel2 = editor;

			timer = new UITimer { Interval = RefreshTime };
			timer.Elapsed += Timer_Elapsed;

			errorTimer = new UITimer { Interval = ErrorDisplayTime };
			errorTimer.Elapsed += ErrorTimer_Elapsed;
		}
예제 #6
0
        protected override void OnUnLoad(EventArgs e)
        {
            base.OnUnLoad(e);

            if (this._devicesSubscription != null)
            {
                this._devicesSubscription.Dispose();
                this._devicesSubscription = null;
            }

            if(_refreshTimer != null)
            {
                _refreshTimer.Dispose();
                _refreshTimer = null;
            }

            this._devices = null;
            this.Content = null;
        }
예제 #7
0
        /// <summary>
        /// Specifies that the binding should only respond to change events after a delay.
        /// </summary>
        /// <remarks>
        /// This is useful if the property/delegate that is bound is expensive to retrieve the new value,
        /// for example to dynamically generate a bitmap based on the state of the model, etc.
        ///
        /// The <paramref name="reset"/> boolean allows you to ensure that the binding is updated periodically when <c>false</c> (default),
        /// or <c>true</c> to wait for the delay period after the last change event.
        /// </remarks>
        /// <param name="delay">The delay, in seconds to wait after the value has changed before updating the binding.</param>
        /// <param name="reset"><c>true</c> to reset the delay every time the event is fired, <c>false</c> to trigger the change at least by the delay interval since the last time it was triggered</param>
        /// <returns>A binding that will delay the change event</returns>
        public IndirectBinding <T> AfterDelay(double delay, bool reset = false)
        {
            UITimer   timer  = null;
            EventArgs args   = null;
            object    sender = null;

            return(new DelegateBinding <object, T>(
                       m => GetValue(m),
                       (m, val) => SetValue(m, val),
                       addChangeEvent: (m, ev) =>
            {
                EventHandler <EventArgs> ev2 = (s, e) =>
                {
                    args = e;
                    sender = s;
                    if (timer == null)
                    {
                        timer = new UITimer {
                            Interval = delay
                        };
                        timer.Elapsed += (s2, e2) =>
                        {
                            timer.Stop();
                            ev(sender, args);
                        };
                    }
                    if (reset || !timer.Started)
                    {
                        timer.Start();
                    }
                };
                AddValueChangedHandler(m, ev2);
            },
                       removeChangeEvent: RemoveValueChangedHandler
                       ));
        }
예제 #8
0
		public UnitTestSection()
		{
			startButton = new Button { Text = "Start Tests", Size = new Size(200, 80) };
			useTestPlatform = new CheckBox { Text = "Use Test Platform" };
			var buttons = new StackLayout
			{
				Padding = new Padding(10),
				Spacing = 5,
				HorizontalContentAlignment = HorizontalAlignment.Center,
				Items = { startButton, useTestPlatform }
			};

			if (Platform.Supports<TreeView>())
			{

				search = new SearchBox();
				search.Focus();
				search.KeyDown += (sender, e) =>
				{
					if (e.KeyData == Keys.Enter)
					{	
						startButton.PerformClick();
						e.Handled = true;
					}
				};

				var timer = new UITimer();
				timer.Interval = 0.5;
				timer.Elapsed += (sender, e) =>
				{
					timer.Stop();
					PopulateTree(search.Text);
				};
				search.TextChanged += (sender, e) => {
					if (timer.Started)
						timer.Stop();
					timer.Start();
				};

				tree = new TreeView();

				tree.Activated += (sender, e) =>
				{
					var item = (TreeItem)tree.SelectedItem;
					if (item != null)
					{
						RunTests(item.Tag as CategoryFilter);
					}
				};

				Content = new StackLayout
				{
					Spacing = 5,
					HorizontalContentAlignment = HorizontalAlignment.Stretch,
					Items = { buttons, search, new StackLayoutItem(tree, expand: true) }
				};
			}
			else
				Content = buttons;

			startButton.Click += (s, e) => RunTests();
		}
예제 #9
0
            protected override void OnUnLoad(EventArgs e)
            {
                base.OnUnLoad(e);

                if (_objectsSubscription != null)
                {
                    _objectsSubscription.Dispose();
                    _objectsSubscription = null;
                }

                if(_searchTimer != null)
                {
                    _searchTimer.Dispose();
                    _searchTimer = null;
                }
            }
예제 #10
0
            protected override void OnLoad(EventArgs e)
            {
                base.OnLoad(e);

                _searchTimer = new UITimer();
                _searchTimer.Interval = .4;
                _searchTimer.Elapsed += _searchRefresh;
            }
예제 #11
0
파일: UITimer.cs 프로젝트: yaram/Eto
 /// <summary>
 /// Raises the elapsed event.
 /// </summary>
 public void OnElapsed(UITimer widget, EventArgs e)
 {
     widget.Platform.Invoke(() => widget.OnElapsed(e));
 }
예제 #12
0
			/// <summary>
			/// Raises the elapsed event.
			/// </summary>
			public void OnElapsed(UITimer widget, EventArgs e)
			{
				widget.Platform.Invoke(() => widget.OnElapsed(e));
			}
예제 #13
0
 /// <summary>
 /// Raises the elapsed event.
 /// </summary>
 public void OnElapsed(UITimer widget, EventArgs e)
 {
     using (widget.Platform.Context)
         widget.OnElapsed(e);
 }
예제 #14
0
		public DirectDrawingSection ()
		{
			timer = new UITimer {
				Interval = 0.01
			};
			drawable = new Drawable ();
			drawable.BackgroundColor = Colors.Black;
			timer.Elapsed += (sender, e) => {
				if (this.ParentWindow == null) {
					timer.Stop ();
					return;
				}

				lock (boxes) {
					if (boxes.Count == 0)
						InitializeBoxes ();

					var bounds = drawable.Size;
					try {
						using (var graphics = drawable.CreateGraphics ()) {
							graphics.Antialias = false;
							foreach (var box in boxes) {
								box.Erase (graphics);
								box.Move (bounds);
								box.Draw (graphics);
							} 
						}
					} catch (NotSupportedException) {
						timer.Stop ();
						this.BackgroundColor = Colors.Red;
						this.Content = new Label { Text = "This platform does not support direct drawing", TextColor = Colors.White, VerticalAlign = VerticalAlign.Middle, HorizontalAlign = HorizontalAlign.Center };
					}
				}
			};

			var layout = new DynamicLayout (new Padding(10));
			layout.AddSeparateRow (null, UseTexturesAndGradients (), null);
			layout.Add (drawable);
			this.Content = layout;
		}
예제 #15
0
 /// <summary>
 /// Disabled future refreshes
 /// </summary>
 /// <param name="e"></param>
 protected override void OnUnLoad(EventArgs e)
 {
     base.OnUnLoad(e);
     _refreshTimer.Stop();
     _refreshTimer = null;
 }
예제 #16
0
		public AppDomainDesignHost()
		{
			eventSink = new AppDomainEventSink { Host = this };
			timer = new UITimer { Interval = 1 };
			timer.Elapsed += Timer_Elapsed;
		}