private void SetDataSource(List <WorkerEntity> entityList)
        {
            if (this.InvokeRequired)
            {
                TaskEventHandler <WorkerEntity> task = new TaskEventHandler <WorkerEntity>(SetDataSource);
                this.Invoke(task, new object[] { entityList });
            }
            else
            {
                //this.dgvDataList.DataSource = entityList;
                this.Clear();
                initializeColumn();

                if (entityList == null)
                {
                    return;
                }
                var userQuery = from user in entityList
                                where user.Del == false
                                select user;

                foreach (var item in userQuery)
                {
                    int i = this.Rows.Add();
                    this.Rows[i].Cells[this.delColumn.Name].Value           = item.Del;
                    this.Rows[i].Cells[this.workerCodeColumn.Name].Value    = item.WorkerCode;
                    this.Rows[i].Cells[this.workerCodeColumn.Name].ReadOnly = item.ReadOnly;
                    this.Rows[i].Cells[this.workerNameColumn.Name].Value    = item.WorkerName;
                }
            }
        }
Example #2
0
        /// <summary>
        /// Begins the execute task.
        /// </summary>
        /// <param name="task">The task.</param>
        /// <param name="context">The context.</param>
        /// <param name="callback">The callback.</param>
        public void BeginExecuteTask(ITask task, ITaskContext context, TaskEventHandler callback)
        {
            RetriableTaskCheck(task, context);
            ExecuteTaskDelegate del = SafeExecuteTask;

            del.BeginInvoke(task, context, EndExecuteTask, new object[] { del, task, context, callback });
        }
Example #3
0
        public TaskIdentity AddTask(float delayTime, TaskEventHandler handler, int triggerTimes = 1, float deltaTime = 0)
        {
            System.Diagnostics.Debug.Assert(delayTime > 0, "DelayTime Invalid");
            System.Diagnostics.Debug.Assert(triggerTimes > -1, "TriggerTimes Invalid");
            System.Diagnostics.Debug.Assert(deltaTime > 0, "DeltaTime Invalid");
            int id = UnityEngine.Random.Range(int.MinValue, int.MaxValue);

            while (mTaskDic.ContainsKey(id))
            {
                id = UnityEngine.Random.Range(int.MinValue, int.MaxValue);
            }
            TaskIdentity taskIdentity = new TaskIdentity();

            taskIdentity.Id = id;
            Task task = new Task();

            task.Identity     = taskIdentity;
            task.ActivateTime = (ulong)(Factor * (mCurrentTime + delayTime));
            task.Handler      = handler;
            task.DeltaTime    = deltaTime;
            task.TriggerTimes = triggerTimes;
            mTaskDic.Add(task.Identity.Id, task);

            if (task.TriggerTimes == 0)
            {
                DelTask(taskIdentity);
            }
            return(taskIdentity);
        }
Example #4
0
		public StatusBarControl ()
		{
			InitializeComponent ();
			DataContext = this;

			ctxHandler = new StatusBarContextHandler (this);

			ShowReady ();

			updateHandler = delegate {
				int ec = 0, wc = 0;

				foreach (MonoDevelop.Ide.Tasks.TaskListEntry t in TaskService.Errors) {
					if (t.Severity == TaskSeverity.Error)
						ec++;
					else if (t.Severity == TaskSeverity.Warning)
						wc++;
				}

				DispatchService.GuiDispatch (delegate {
					if (ec > 0) {
						BuildResultPanelVisibility = Visibility.Visible;
						BuildResultCount = ec;
						BuildResultIcon = Stock.Error.GetImageSource (Xwt.IconSize.Small);
					} else if (wc > 0) {
						BuildResultPanelVisibility = Visibility.Visible;
						BuildResultCount = wc;
						BuildResultIcon = Stock.Warning.GetImageSource (Xwt.IconSize.Small);
					} else
						BuildResultPanelVisibility = Visibility.Collapsed;
				});
			};
			TaskService.Errors.TasksAdded += updateHandler;
			TaskService.Errors.TasksRemoved += updateHandler;
		}
Example #5
0
File: MainForm.cs Project: zzyn/poc
        /// <summary>
        /// 匹配 任务进度处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnMatchTaskProcessChanged(object sender, TaskEventArgs e)
        {
            //不在UI线程上,异步调用
            if (InvokeRequired)
            {
                TaskEventHandler TPChanged = new TaskEventHandler(OnMatchTaskProcessChanged);

                //this.BeginInvoke(TPChanged, new object[] { sender, e });
                this.Invoke(TPChanged, new object[] { sender, e });
            }
            //在UI线程上,更新控件状态
            else
            {
                MatchDataEntity entity = e.Result as MatchDataEntity;

                this.tspbMatch.Maximum = entity.TotalCount;
                this.tspbMatch.Value   = e.Progress;


                this.tslMatch.Text = string.Format("{0}/{1}", this.tspbMatch.Value, this.tspbMatch.Maximum);

                //DataTable dt = entity.DataTable;
                if (entity.MatchRow != null)
                {
                    this.MatchTable.ImportRow(entity.MatchRow);
                }



                //Application.DoEvents();
            }
        }
Example #6
0
 private void DoEventHandler(TaskEventHandler hander, TaskEventArg e)
 {
     if (hander != null)
     {
         hander.Invoke(this, e);
     }
 }
		public EventHandlerTaskAsyncHelper (TaskEventHandler handler)
		{
			if (handler == null)
				throw new ArgumentNullException ("handler");

			taskEventHandler = handler;
			beginEventHandler = GetAsyncResult;
		}
        public EventHandlerTaskAsyncHelper(TaskEventHandler handler) {
            if (handler == null) {
                throw new ArgumentNullException("handler");
            }

            BeginEventHandler = (sender, e, cb, extraData) => TaskAsyncHelper.BeginTask(() => handler(sender, e), cb, extraData);
            EndEventHandler = TaskAsyncHelper.EndTask;
        }
Example #9
0
 protected void DoEventHandler(TaskEventHandler handler, TaskEventArg e)
 {
     if (handler != null)
     {
         handler.Invoke(this, e);
         //hander.BeginInvoke(this);多线程
     }
 }
Example #10
0
 // Overloaded in case you want to have a call back.
 public object Execute(ITaskContext context, TaskEventHandler callBack)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     return(ExecuteTask(context, callBack));
 }
        private void ExecuteTaskEvent(object EventKey)
        {
            TaskEventHandler handler = this.Events[EventKey] as TaskEventHandler;

            if (handler != null)
            {
                handler();
            }
        }
        public EventHandlerTaskAsyncHelper(TaskEventHandler handler)
        {
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }

            BeginEventHandler = (sender, e, cb, extraData) => TaskAsyncHelper.BeginTask(() => handler(sender, e), cb, extraData);
            EndEventHandler   = TaskAsyncHelper.EndTask;
        }
        public EventHandlerTaskAsyncHelper(TaskEventHandler handler)
        {
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }

            taskEventHandler  = handler;
            beginEventHandler = GetAsyncResult;
        }
Example #14
0
        public StatusBarControl()
        {
            InitializeComponent();
            DataContext = this;

            ctxHandler = new StatusBarContextHandler(this);

            ShowReady();

            updateHandler = delegate {
                int ec = 0, wc = 0;

                foreach (MonoDevelop.Ide.Tasks.TaskListEntry t in TaskService.Errors)
                {
                    if (t.Severity == TaskSeverity.Error)
                    {
                        ec++;
                    }
                    else if (t.Severity == TaskSeverity.Warning)
                    {
                        wc++;
                    }
                }

                Runtime.RunInMainThread(delegate {
                    if (ec > 0)
                    {
                        BuildResultPanelVisibility = Visibility.Visible;
                        BuildResultCount           = ec;
                        BuildResultIcon            = Stock.Error.GetStockIcon().WithSize(Xwt.IconSize.Small);
                    }
                    else if (wc > 0)
                    {
                        BuildResultPanelVisibility = Visibility.Visible;
                        BuildResultCount           = wc;
                        BuildResultIcon            = Stock.Warning.GetStockIcon().WithSize(Xwt.IconSize.Small);
                    }
                    else
                    {
                        BuildResultPanelVisibility = Visibility.Collapsed;
                    }
                });
            };
            TaskService.Errors.TasksAdded          += updateHandler;
            TaskService.Errors.TasksRemoved        += updateHandler;
            BrandingService.ApplicationNameChanged += ApplicationNameChanged;

            StatusText.ToolTipOpening += (o, e) => {
                e.Handled = !TextTrimmed();
            };
        }
Example #15
0
        protected override IAsyncResult GetAsyncResult(Func <Task> taskFactory, AsyncCallback callback, object state)
        {
            Assert.IsNull(helper, "GetAsyncResult#A01");

            TaskEventHandler handler = (sender, e) => {
                Assert.AreSame(expectedSender, sender, "GetAsyncResult#A02");
                Assert.AreSame(expectedEventArgs, e, "GetAsyncResult#A03");

                return(taskFactory());
            };

            helper = new EventHandlerTaskAsyncHelper(handler);
            return(helper.BeginEventHandler(expectedSender, expectedEventArgs, callback, state));
        }
Example #16
0
        static void Main(string[] args)
        {
            TaskEventHandler handler = new TaskEventHandler();
            int result = handler.ProcessContactlessTransaction();

            Console.WriteLine("cmd: ReadCard          - status=0x0{0:X4}", result);

            if (result == 0x9000)
            {
                result = handler.ContinueContactlessTransaction();
                Console.WriteLine("cmd: CLess Transaction - status=0x0{0:X4}", result);
            }

            Console.WriteLine("\r\nPress any key to exit...");
            Console.ReadKey();
        }
Example #17
0
        public StatusBarControl()
        {
            InitializeComponent();
            DataContext = this;

            ctxHandler = new StatusBarContextHandler(this);

            ShowReady();

            updateHandler = delegate {
                int ec = 0, wc = 0;

                foreach (MonoDevelop.Ide.Tasks.TaskListEntry t in TaskService.Errors)
                {
                    if (t.Severity == TaskSeverity.Error)
                    {
                        ec++;
                    }
                    else if (t.Severity == TaskSeverity.Warning)
                    {
                        wc++;
                    }
                }

                DispatchService.GuiDispatch(delegate {
                    if (ec > 0)
                    {
                        BuildResultPanelVisibility = Visibility.Visible;
                        BuildResultCount           = ec;
                        BuildResultIcon            = Stock.Error.GetImageSource(Xwt.IconSize.Small);
                    }
                    else if (wc > 0)
                    {
                        BuildResultPanelVisibility = Visibility.Visible;
                        BuildResultCount           = wc;
                        BuildResultIcon            = Stock.Warning.GetImageSource(Xwt.IconSize.Small);
                    }
                    else
                    {
                        BuildResultPanelVisibility = Visibility.Collapsed;
                    }
                });
            };
            TaskService.Errors.TasksAdded   += updateHandler;
            TaskService.Errors.TasksRemoved += updateHandler;
        }
        protected void AsyncInvoke(TaskEventHandler eventhandler, TaskEventArgs args)
        {
//			TaskEventHandler[] tpcs = (TaskEventHandler[])eventhandler.GetInvocationList();
            Delegate[] tpcs = eventhandler.GetInvocationList();
            foreach (TaskEventHandler tpc in tpcs)
            {
                if (tpc.Target is System.Windows.Forms.Control)
                {
                    Control targetForm = tpc.Target as System.Windows.Forms.Control;
                    targetForm.BeginInvoke(tpc, new object[] { this, args });
                }
                else
                {
                    tpc.BeginInvoke(this, args, null, null);
                }
            }
        }
Example #19
0
        private object ExecuteTask(ITaskContext context, TaskEventHandler callBack)
        {
            _callBack    = callBack;
            _taskContext = context;
            object taskResult  = null;
            bool   bExecutedOK = false;

            try
            {
                //using (BatchUpdate batch = new BatchUpdate())
                //{
                taskResult = PerformTask(_taskContext as TaskContext);
                //}
                bExecutedOK = !(taskResult is Exception);
                if (!bExecutedOK)
                {
                    throw ((Exception)taskResult);
                }
                return(taskResult);
            }
            catch (Exception ex)
            {
                taskResult = ex;
                WaitForRetry(ex);
                if (!CanRetry)
                {
                    return(ex); // Tried the best with no luck
                }
                return(false);  // In the middle of re-try
            }
            finally
            {
                var args = new TaskEventArgs(this, TaskContext, taskResult);
                if (callBack != null)
                {
                    callBack(this, args);
                }
                if (bExecutedOK)
                {
                    OnTaskCompleted(args);
                }
                OnTaskExecuted(args);
            }
        }
		public StatusBarControl ()
		{
			InitializeComponent ();
			DataContext = this;

			ctxHandler = new StatusBarContextHandler (this);

			ShowReady ();

			updateHandler = delegate {
				int ec = 0, wc = 0;

				foreach (MonoDevelop.Ide.Tasks.TaskListEntry t in TaskService.Errors) {
					if (t.Severity == TaskSeverity.Error)
						ec++;
					else if (t.Severity == TaskSeverity.Warning)
						wc++;
				}

				Runtime.RunInMainThread (delegate {
					if (ec > 0) {
						BuildResultPanelVisibility = Visibility.Visible;
						BuildResultCount = ec;
						BuildResultIcon = Stock.Error.GetStockIcon ().WithSize (Xwt.IconSize.Small);
					} else if (wc > 0) {
						BuildResultPanelVisibility = Visibility.Visible;
						BuildResultCount = wc;
						BuildResultIcon = Stock.Warning.GetStockIcon ().WithSize (Xwt.IconSize.Small);
					} else
						BuildResultPanelVisibility = Visibility.Collapsed;
				});
			};
			TaskService.Errors.TasksAdded += updateHandler;
			TaskService.Errors.TasksRemoved += updateHandler;
			BrandingService.ApplicationNameChanged += ApplicationNameChanged;

			StatusText.ToolTipOpening += (o, e) => {
				e.Handled = !TextTrimmed ();
			};
		}
Example #21
0
        /// <summary>
        /// Executes the task.
        /// </summary>
        /// <param name="task">The task.</param>
        /// <param name="context">The context.</param>
        /// <param name="callback">The callback.</param>
        /// <returns></returns>
        public object ExecuteTask(ITask task, ITaskContext context, TaskEventHandler callback)
        {
            RetriableTaskCheck(task, context);
            object taskResult = SafeExecuteTask(task, context);

            var args = new TaskEventArgs(task, context, taskResult);

            if (callback != null)
            {
                //callback.BeginInvoke(this,args,null,null);
                callback(this, args);
            }

            if (args.ResultIsException)
            {
                OnTaskError(args);
            }
            else
            {
                OnTaskComplete(args);
            }

            return(taskResult);
        }
Example #22
0
		public StatusBar ()
		{
			AllowsEditingTextAttributes = Selectable = Editable = false;

			textField.Cell = new VerticallyCenteredTextFieldCell (yOffset: -0.5f);
			textField.Cell.StringValue = "";
			textField.Cell.PlaceholderAttributedString = GetStatusString (BrandingService.ApplicationName, NSColor.DisabledControlText);

			// The rect is empty because we use InVisibleRect to track the whole of the view.
			textFieldArea = new NSTrackingArea (CGRect.Empty, NSTrackingAreaOptions.MouseEnteredAndExited | NSTrackingAreaOptions.ActiveInKeyWindow | NSTrackingAreaOptions.InVisibleRect, this, null);
			textField.AddTrackingArea (textFieldArea);

			imageView.Image = ImageService.GetIcon (Stock.StatusSteady).ToNSImage ();

			buildResults = new BuildResultsView ();
			buildResults.Hidden = true;
			AddSubview (buildResults);

			// Fixes a render glitch of a whiter bg than the others.
			if (MacSystemInformation.OsVersion >= MacSystemInformation.Yosemite)
				BezelStyle = NSTextFieldBezelStyle.Rounded;

			WantsLayer = true;
			Layer.CornerRadius = MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan ? 6 : 4;
			ctxHandler = new StatusBarContextHandler (this);

			updateHandler = delegate {
				int ec = 0, wc = 0;

				foreach (var t in TaskService.Errors) {
					if (t.Severity == TaskSeverity.Error)
						ec++;
					else if (t.Severity == TaskSeverity.Warning)
						wc++;
				}

				Runtime.RunInMainThread (delegate {
					buildResults.Hidden = (ec == 0 && wc == 0);
					buildResults.ResultCount = ec > 0 ? ec : wc;

					buildImageId = ec > 0 ? "md-status-error-count" : "md-status-warning-count";
					buildResults.IconImage = ImageService.GetIcon (buildImageId, Gtk.IconSize.Menu).ToNSImage ();

					RepositionStatusIcons ();
				});
			};

			updateHandler (null, null);

			TaskService.Errors.TasksAdded += updateHandler;
			TaskService.Errors.TasksRemoved += updateHandler;

			AddSubview (imageView);
			AddSubview (textField);
		}
Example #23
0
        protected virtual void OnPaused(TaskEventArg e)
        {
            TaskEventHandler handler = Paused;

            DoEventHandler(handler, e);
        }
Example #24
0
        public StatusBar()
        {
            var nsa = (INSAccessibility)this;

            // Pretend that this button is a Group
            AccessibilityRole           = NSAccessibilityRoles.GroupRole;
            nsa.AccessibilityIdentifier = "MainToolbar.StatusDisplay";

            Cell       = new ColoredButtonCell();
            BezelStyle = NSBezelStyle.TexturedRounded;
            Title      = "";
            Enabled    = false;

            LoadStyles();

            // We don't need to resize the Statusbar here as a style change will trigger a complete relayout of the Awesomebar
            Ide.Gui.Styles.Changed += LoadStyles;

            textField.Cell             = new VerticallyCenteredTextFieldCell(0f);
            textField.Cell.StringValue = "";

            textField.AccessibilityRole    = NSAccessibilityRoles.StaticTextRole;
            textField.AccessibilityEnabled = true;
            textField.AccessibilityHelp    = GettextCatalog.GetString("Status of the current operation");

            var tfNSA = (INSAccessibility)textField;

            tfNSA.AccessibilityIdentifier = "MainToolbar.StatusDisplay.Status";

            UpdateApplicationNamePlaceholderText();

            // The rect is empty because we use InVisibleRect to track the whole of the view.
            textFieldArea = new NSTrackingArea(CGRect.Empty, NSTrackingAreaOptions.MouseEnteredAndExited | NSTrackingAreaOptions.ActiveInKeyWindow | NSTrackingAreaOptions.InVisibleRect, this, null);
            textField.AddTrackingArea(textFieldArea);

            imageView.Frame = new CGRect(0.5, 0, 0, 0);
            imageView.Image = ImageService.GetIcon(Stock.StatusSteady).ToNSImage();

            // Hide this image from accessibility
            imageView.AccessibilityElement = false;

            buildResults        = new BuildResultsView();
            buildResults.Hidden = true;

            cancelButton            = new CancelButton();
            cancelButton.Activated += (o, e) => {
                cts?.Cancel();
            };

            ctxHandler = new StatusBarContextHandler(this);

            updateHandler = delegate {
                int ec = 0, wc = 0;

                foreach (var t in TaskService.Errors)
                {
                    if (t.Severity == TaskSeverity.Error)
                    {
                        ec++;
                    }
                    else if (t.Severity == TaskSeverity.Warning)
                    {
                        wc++;
                    }
                }

                Runtime.RunInMainThread(delegate {
                    buildResults.Hidden      = (ec == 0 && wc == 0);
                    buildResults.ResultCount = ec > 0 ? ec : wc;
                    buildResults.Type        = ec > 0 ? BuildResultsView.ResultsType.Error : BuildResultsView.ResultsType.Warning;

                    buildImageId           = ec > 0 ? "md-status-error-count" : "md-status-warning-count";
                    buildResults.IconImage = ImageService.GetIcon(buildImageId, Gtk.IconSize.Menu).ToNSImage();

                    RepositionStatusIcons();
                });
            };

            updateHandler(null, null);

            TaskService.Errors.TasksAdded          += updateHandler;
            TaskService.Errors.TasksRemoved        += updateHandler;
            BrandingService.ApplicationNameChanged += ApplicationNameChanged;

            AddSubview(cancelButton);
            AddSubview(buildResults);
            AddSubview(imageView);
            AddSubview(textField);

            progressView = new ProgressView();
            AddSubview(progressView);

            var newChildren = new NSObject [] {
                textField, buildResults, progressView
            };

            AccessibilityChildren = newChildren;
        }
Example #25
0
        public Widget CreateBuildResultsWidget(Orientation orientation)
        {
            EventBox ebox = new EventBox();

            Gtk.Box box;
            if (orientation == Orientation.Horizontal)
            {
                box = new HBox();
            }
            else
            {
                box = new VBox();
            }
            box.Spacing = 3;

            Gdk.Pixbuf errorIcon     = ImageService.GetPixbuf(StockIcons.Error, IconSize.Menu);
            Gdk.Pixbuf noErrorIcon   = ImageService.MakeGrayscale(errorIcon);            // creates a new pixbuf instance
            Gdk.Pixbuf warningIcon   = ImageService.GetPixbuf(StockIcons.Warning, IconSize.Menu);
            Gdk.Pixbuf noWarningIcon = ImageService.MakeGrayscale(warningIcon);          // creates a new pixbuf instance

            Gtk.Image errorImage   = new Gtk.Image(errorIcon);
            Gtk.Image warningImage = new Gtk.Image(warningIcon);

            box.PackStart(errorImage, false, false, 0);
            Label errors = new Gtk.Label();

            box.PackStart(errors, false, false, 0);

            box.PackStart(warningImage, false, false, 0);
            Label warnings = new Gtk.Label();

            box.PackStart(warnings, false, false, 0);
            box.NoShowAll = true;
            box.Show();

            TaskEventHandler updateHandler = delegate {
                int ec = 0, wc = 0;
                foreach (Task t in TaskService.Errors)
                {
                    if (t.Severity == TaskSeverity.Error)
                    {
                        ec++;
                    }
                    else if (t.Severity == TaskSeverity.Warning)
                    {
                        wc++;
                    }
                }
                errors.Visible     = ec > 0;
                errors.Text        = ec.ToString();
                errorImage.Visible = ec > 0;

                warnings.Visible     = wc > 0;
                warnings.Text        = wc.ToString();
                warningImage.Visible = wc > 0;
                ebox.Visible         = ec > 0 || wc > 0;
                UpdateSeparators();
            };

            updateHandler(null, null);

            TaskService.Errors.TasksAdded   += updateHandler;
            TaskService.Errors.TasksRemoved += updateHandler;

            box.Destroyed += delegate {
                noErrorIcon.Dispose();
                noWarningIcon.Dispose();
                TaskService.Errors.TasksAdded   -= updateHandler;
                TaskService.Errors.TasksRemoved -= updateHandler;
            };

            ebox.VisibleWindow = false;
            ebox.Add(box);
            ebox.ShowAll();
            ebox.ButtonReleaseEvent += delegate {
                var pad = IdeApp.Workbench.GetPad <MonoDevelop.Ide.Gui.Pads.ErrorListPad> ();
                pad.BringToFront();
            };

            errors.Visible       = false;
            errorImage.Visible   = false;
            warnings.Visible     = false;
            warningImage.Visible = false;

            return(ebox);
        }
Example #26
0
 //��UI�߳�,������½�����
 private void OnTaskProgressChanged1( object sender,TaskEventArgs e )
 {
     if (InvokeRequired )		//����UI�߳���,�첽����
     {
         TaskEventHandler TPChanged1 = new TaskEventHandler( OnTaskProgressChanged1 );
         this.BeginInvoke(TPChanged1,new object[] {sender,e});
         Console.WriteLine("InvokeRequired=true");
     }
     else
     {
         progressBar.Value = e.Progress;
     }
 }
Example #27
0
        public Widget CreateBuildResultsWidget(Orientation orientation)
        {
            EventBox ebox = new EventBox();

            Gtk.Box box;
            if (orientation == Orientation.Horizontal)
            {
                box = new HBox();
            }
            else
            {
                box = new VBox();
            }
            box.Spacing = 3;

            var errorIcon   = ImageService.GetIcon(StockIcons.Error).WithSize(Xwt.IconSize.Small);
            var warningIcon = ImageService.GetIcon(StockIcons.Warning).WithSize(Xwt.IconSize.Small);

            var errorImage   = new Xwt.ImageView(errorIcon);
            var warningImage = new Xwt.ImageView(warningIcon);

            box.PackStart(errorImage.ToGtkWidget(), false, false, 0);
            Label errors = new Gtk.Label();

            box.PackStart(errors, false, false, 0);

            box.PackStart(warningImage.ToGtkWidget(), false, false, 0);
            Label warnings = new Gtk.Label();

            box.PackStart(warnings, false, false, 0);
            box.NoShowAll = true;
            box.Show();

            TaskEventHandler updateHandler = delegate {
                int ec = 0, wc = 0;

                foreach (Task t in TaskService.Errors)
                {
                    if (t.Severity == TaskSeverity.Error)
                    {
                        ec++;
                    }
                    else if (t.Severity == TaskSeverity.Warning)
                    {
                        wc++;
                    }
                }


                using (var font = FontService.SansFont.CopyModified(0.8d)) {
                    errors.Visible = ec > 0;
                    errors.ModifyFont(font);
                    errors.Text        = ec.ToString();
                    errorImage.Visible = ec > 0;

                    warnings.Visible = wc > 0;
                    warnings.ModifyFont(font);
                    warnings.Text        = wc.ToString();
                    warningImage.Visible = wc > 0;
                }

                ebox.Visible = ec > 0 || wc > 0;

                UpdateSeparators();
            };

            updateHandler(null, null);

            TaskService.Errors.TasksAdded   += updateHandler;
            TaskService.Errors.TasksRemoved += updateHandler;

            box.Destroyed += delegate {
                TaskService.Errors.TasksAdded   -= updateHandler;
                TaskService.Errors.TasksRemoved -= updateHandler;
            };

            ebox.VisibleWindow = false;
            ebox.Add(box);
            ebox.ShowAll();
            ebox.ButtonReleaseEvent += delegate {
                var pad = IdeApp.Workbench.GetPad <MonoDevelop.Ide.Gui.Pads.ErrorListPad> ();
                pad.BringToFront();
            };

            errors.Visible       = false;
            errorImage.Visible   = false;
            warnings.Visible     = false;
            warningImage.Visible = false;

            return(ebox);
        }
Example #28
0
		public StatusBar ()
		{
			AllowsEditingTextAttributes = Selectable = Editable = false;

			textField.Cell = new VerticallyCenteredTextFieldCell (yOffset: -0.5f);
			textField.Cell.StringValue = "";
			textField.Cell.PlaceholderAttributedString = GetStatusString (BrandingService.ApplicationName, NSColor.DisabledControlText);
			imageView.Image = ImageService.GetIcon (Stock.StatusSteady).ToNSImage ();

			// Fixes a render glitch of a whiter bg than the others.
			if (MacSystemInformation.OsVersion >= MacSystemInformation.Yosemite)
				BezelStyle = NSTextFieldBezelStyle.Rounded;

			WantsLayer = true;
			Layer.CornerRadius = 4;
			ctxHandler = new StatusBarContextHandler (this);

			updateHandler = delegate {
				int ec=0, wc=0;

				foreach (Task t in TaskService.Errors) {
					if (t.Severity == TaskSeverity.Error)
						ec++;
					else if (t.Severity == TaskSeverity.Warning)
						wc++;
				}

				DispatchService.GuiDispatch (delegate {
					if (ec > 0) {
						buildResultVisible = true;
						buildResultText.AttributedString = new NSAttributedString (ec.ToString (), foregroundColor: NSColor.Text,
							font: NSFont.SystemFontOfSize (NSFont.SmallSystemFontSize - 1));
						buildResultText.ContentsScale = Window.BackingScaleFactor;
						buildResultIcon.SetImage (buildImageId = "md-status-error-count", Window.BackingScaleFactor);
					} else if (wc > 0) {
						buildResultVisible = true;
						buildResultText.AttributedString = new NSAttributedString (wc.ToString (), foregroundColor: NSColor.Text,
							font: NSFont.SystemFontOfSize (NSFont.SmallSystemFontSize - 1));
						buildResultText.ContentsScale = Window.BackingScaleFactor;
						buildResultIcon.SetImage (buildImageId = "md-status-warning-count", Window.BackingScaleFactor);
					} else
						buildResultVisible = false;

					CATransaction.DisableActions = true;
					nfloat buildResultPosition = DrawBuildResults ();
					CATransaction.DisableActions = false;
					if (buildResultPosition == nfloat.PositiveInfinity)
						return;
					textField.SetFrameSize (new CGSize (buildResultPosition - 6 - textField.Frame.Left, Frame.Height));
				});
			};

			updateHandler (null, null);

			TaskService.Errors.TasksAdded += updateHandler;
			TaskService.Errors.TasksRemoved += updateHandler;

			NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidChangeBackingPropertiesNotification, notif => DispatchService.GuiDispatch (() => {
				if (Window == null)
					return;

				ReconstructString ();
				foreach (var layer in Layer.Sublayers) {
					if (layer.Name != null && layer.Name.StartsWith (StatusIconPrefixId, StringComparison.Ordinal))
						layer.SetImage (layerToStatus [layer.Name].Image, Window.BackingScaleFactor);
				}
				if (buildResultVisible) {
					buildResultIcon.SetImage (buildImageId, Window.BackingScaleFactor);
					buildResultText.ContentsScale = Window.BackingScaleFactor;
				}
			}));

			AddSubview (imageView);
			AddSubview (textField);
		}
Example #29
0
        public StatusBar()
        {
            AllowsEditingTextAttributes = Selectable = Editable = false;

            textField.Cell             = new VerticallyCenteredTextFieldCell(yOffset: -0.5f);
            textField.Cell.StringValue = "";
            textField.Cell.PlaceholderAttributedString = GetStatusString(BrandingService.ApplicationName, NSColor.DisabledControlText);
            imageView.Image = ImageService.GetIcon(Stock.StatusSteady).ToNSImage();

            // Fixes a render glitch of a whiter bg than the others.
            if (MacSystemInformation.OsVersion >= MacSystemInformation.Yosemite)
            {
                BezelStyle = NSTextFieldBezelStyle.Rounded;
            }

            WantsLayer         = true;
            Layer.CornerRadius = MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan ? 6 : 4;
            ctxHandler         = new StatusBarContextHandler(this);

            updateHandler = delegate {
                int ec = 0, wc = 0;

                foreach (Task t in TaskService.Errors)
                {
                    if (t.Severity == TaskSeverity.Error)
                    {
                        ec++;
                    }
                    else if (t.Severity == TaskSeverity.Warning)
                    {
                        wc++;
                    }
                }

                DispatchService.GuiDispatch(delegate {
                    if (ec > 0)
                    {
                        buildResultVisible = true;
                        buildResultText.AttributedString = new NSAttributedString(ec.ToString(), foregroundColor: NSColor.Text,
                                                                                  font: NSFont.SystemFontOfSize(NSFont.SmallSystemFontSize - 1));
                        buildResultText.ContentsScale         = Window.BackingScaleFactor;
                        buildResultIcon.SetImage(buildImageId = "md-status-error-count", Window.BackingScaleFactor);
                    }
                    else if (wc > 0)
                    {
                        buildResultVisible = true;
                        buildResultText.AttributedString = new NSAttributedString(wc.ToString(), foregroundColor: NSColor.Text,
                                                                                  font: NSFont.SystemFontOfSize(NSFont.SmallSystemFontSize - 1));
                        buildResultText.ContentsScale         = Window.BackingScaleFactor;
                        buildResultIcon.SetImage(buildImageId = "md-status-warning-count", Window.BackingScaleFactor);
                    }
                    else
                    {
                        buildResultVisible = false;
                    }

                    CATransaction.DisableActions = true;
                    nfloat buildResultPosition   = DrawBuildResults();
                    CATransaction.DisableActions = false;
                    if (buildResultPosition == nfloat.PositiveInfinity)
                    {
                        return;
                    }
                    textField.SetFrameSize(new CGSize(buildResultPosition - 6 - textField.Frame.Left, Frame.Height));
                });
            };

            updateHandler(null, null);

            TaskService.Errors.TasksAdded   += updateHandler;
            TaskService.Errors.TasksRemoved += updateHandler;

            NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.DidChangeBackingPropertiesNotification, notif => DispatchService.GuiDispatch(() => {
                if (Window == null)
                {
                    return;
                }

                ReconstructString(updateTrackingAreas: true);
                foreach (var layer in Layer.Sublayers)
                {
                    if (layer.Name != null && layer.Name.StartsWith(StatusIconPrefixId, StringComparison.Ordinal))
                    {
                        layer.SetImage(layerToStatus [layer.Name].Image, Window.BackingScaleFactor);
                    }
                }
                if (buildResultVisible)
                {
                    buildResultIcon.SetImage(buildImageId, Window.BackingScaleFactor);
                    buildResultText.ContentsScale = Window.BackingScaleFactor;
                }
            }));

            AddSubview(imageView);
            AddSubview(textField);
        }
Example #30
0
        protected virtual void OnStopping(TaskEventArg e)
        {
            TaskEventHandler handler = Stopping;

            DoEventHandler(handler, e);
        }
Example #31
0
        public Widget CreateLabel(Orientation orientation)
        {
            Gtk.Box box;
            if (orientation == Orientation.Horizontal)
            {
                box = new HBox();
            }
            else
            {
                box = new VBox();
            }
            box.Spacing = 3;

            Gdk.Pixbuf errorIcon     = ImageService.GetPixbuf(MonoDevelop.Ide.Gui.Stock.Error, IconSize.Menu);
            Gdk.Pixbuf noErrorIcon   = ImageService.MakeGrayscale(errorIcon);            // creates a new pixbuf instance
            Gdk.Pixbuf warningIcon   = ImageService.GetPixbuf(MonoDevelop.Ide.Gui.Stock.Warning, IconSize.Menu);
            Gdk.Pixbuf noWarningIcon = ImageService.MakeGrayscale(warningIcon);          // creates a new pixbuf instance

            Gtk.Image errorImage   = new Gtk.Image(errorIcon);
            Gtk.Image warningImage = new Gtk.Image(warningIcon);

            box.PackStart(errorImage, false, false, 0);
            Label errors = new Gtk.Label();

            box.PackStart(errors, false, false, 0);

            box.PackStart(warningImage, false, false, 0);
            Label warnings = new Gtk.Label();

            box.PackStart(warnings, false, false, 0);

            TaskEventHandler updateHandler = delegate {
                int ec = 0, wc = 0;
                foreach (Task t in TaskService.Errors)
                {
                    if (t.Severity == TaskSeverity.Error)
                    {
                        ec++;
                    }
                    else if (t.Severity == TaskSeverity.Warning)
                    {
                        wc++;
                    }
                }
                errors.Text         = ec.ToString();
                errorImage.Pixbuf   = ec > 0 ? errorIcon : noErrorIcon;
                warnings.Text       = wc.ToString();
                warningImage.Pixbuf = wc > 0 ? warningIcon : noWarningIcon;
            };

            updateHandler(null, null);

            TaskService.Errors.TasksAdded   += updateHandler;
            TaskService.Errors.TasksRemoved += updateHandler;

            box.Destroyed += delegate {
                noErrorIcon.Dispose();
                noWarningIcon.Dispose();
                TaskService.Errors.TasksAdded   -= updateHandler;
                TaskService.Errors.TasksRemoved -= updateHandler;
            };
            return(box);
        }
Example #32
0
        protected virtual void OnStateChanged(TaskEventArg e)
        {
            TaskEventHandler handler = StateChanged;

            DoEventHandler(handler, e);
        }
Example #33
0
 /// <summary>
 /// �첽���ùҽ��¼�ί��
 /// </summary>
 /// <param name="eventhandler">�¼�����������</param>
 /// <param name="args">�¼���Ϣ</param>
 protected void AsyncInvoke(TaskEventHandler eventhandler,TaskEventArgs args)
 {
     //			TaskEventHandler[] tpcs = (TaskEventHandler[])eventhandler.GetInvocationList();
     Delegate[] tpcs = eventhandler.GetInvocationList();
     foreach(TaskEventHandler tpc in tpcs)
     {
         if ( tpc.Target is System.Windows.Forms.Control )
         {
             Control targetForm = tpc.Target as System.Windows.Forms.Control;
             targetForm.BeginInvoke( tpc,new object[] { this, args } );
         }
         else
         {
             tpc.BeginInvoke(this, args ,null,null); //�첽����,����󲻹�
         }
     }
 }
Example #34
0
        protected virtual void OnContinued(TaskEventArg e)
        {
            TaskEventHandler handler = Continued;

            DoEventHandler(handler, e);
        }
Example #35
0
		public StatusBar ()
		{
			Cell = new ColoredButtonCell ();
			BezelStyle = NSBezelStyle.TexturedRounded;
			Title = "";
			Enabled = false;

			LoadStyles ();

			// We don't need to resize the Statusbar here as a style change will trigger a complete relayout of the Awesomebar
			Ide.Gui.Styles.Changed += LoadStyles;

			textField.Cell = new VerticallyCenteredTextFieldCell (0f);
			textField.Cell.StringValue = "";
			UpdateApplicationNamePlaceholderText ();

			// The rect is empty because we use InVisibleRect to track the whole of the view.
			textFieldArea = new NSTrackingArea (CGRect.Empty, NSTrackingAreaOptions.MouseEnteredAndExited | NSTrackingAreaOptions.ActiveInKeyWindow | NSTrackingAreaOptions.InVisibleRect, this, null);
			textField.AddTrackingArea (textFieldArea);

			imageView.Frame = new CGRect (0.5, 0, 0, 0);
			imageView.Image = ImageService.GetIcon (Stock.StatusSteady).ToNSImage ();

			buildResults = new BuildResultsView ();
			buildResults.Hidden = true;

			cancelButton = new CancelButton ();
			cancelButton.Activated += (o, e) => {
				cts?.Cancel ();
			};

			ctxHandler = new StatusBarContextHandler (this);

			updateHandler = delegate {
				int ec = 0, wc = 0;

				foreach (var t in TaskService.Errors) {
					if (t.Severity == TaskSeverity.Error)
						ec++;
					else if (t.Severity == TaskSeverity.Warning)
						wc++;
				}

				Runtime.RunInMainThread (delegate {
					buildResults.Hidden = (ec == 0 && wc == 0);
					buildResults.ResultCount = ec > 0 ? ec : wc;

					buildImageId = ec > 0 ? "md-status-error-count" : "md-status-warning-count";
					buildResults.IconImage = ImageService.GetIcon (buildImageId, Gtk.IconSize.Menu).ToNSImage ();

					RepositionStatusIcons ();
				});
			};

			updateHandler (null, null);

			TaskService.Errors.TasksAdded += updateHandler;
			TaskService.Errors.TasksRemoved += updateHandler;
			BrandingService.ApplicationNameChanged += ApplicationNameChanged;

			AddSubview (cancelButton);
			AddSubview (buildResults);
			AddSubview (imageView);
			AddSubview (textField);

			progressView = new ProgressView ();
			AddSubview (progressView);
		}
Example #36
0
 protected void DoEventHandler(TaskEventHandler handler, TaskEventArg e)
 {
     if (handler != null)
     {
         handler.Invoke(this, e);
         //hander.BeginInvoke(this);多线程
     }
 }
Example #37
0
        public StatusBar()
        {
            Cell       = new ColoredButtonCell();
            BezelStyle = NSBezelStyle.TexturedRounded;
            Title      = "";
            Enabled    = false;

            LoadStyles();

            // We don't need to resize the Statusbar here as a style change will trigger a complete relayout of the Awesomebar
            Ide.Gui.Styles.Changed += LoadStyles;

            textField.Cell             = new VerticallyCenteredTextFieldCell(0f);
            textField.Cell.StringValue = "";
            UpdateApplicationNamePlaceholderText();

            // The rect is empty because we use InVisibleRect to track the whole of the view.
            textFieldArea = new NSTrackingArea(CGRect.Empty, NSTrackingAreaOptions.MouseEnteredAndExited | NSTrackingAreaOptions.ActiveInKeyWindow | NSTrackingAreaOptions.InVisibleRect, this, null);
            textField.AddTrackingArea(textFieldArea);

            imageView.Frame = new CGRect(0.5, 0, 0, 0);
            imageView.Image = ImageService.GetIcon(Stock.StatusSteady).ToNSImage();

            buildResults        = new BuildResultsView();
            buildResults.Hidden = true;

            ctxHandler = new StatusBarContextHandler(this);

            updateHandler = delegate {
                int ec = 0, wc = 0;

                foreach (var t in TaskService.Errors)
                {
                    if (t.Severity == TaskSeverity.Error)
                    {
                        ec++;
                    }
                    else if (t.Severity == TaskSeverity.Warning)
                    {
                        wc++;
                    }
                }

                Runtime.RunInMainThread(delegate {
                    buildResults.Hidden      = (ec == 0 && wc == 0);
                    buildResults.ResultCount = ec > 0 ? ec : wc;

                    buildImageId           = ec > 0 ? "md-status-error-count" : "md-status-warning-count";
                    buildResults.IconImage = ImageService.GetIcon(buildImageId, Gtk.IconSize.Menu).ToNSImage();

                    RepositionStatusIcons();
                });
            };

            updateHandler(null, null);

            TaskService.Errors.TasksAdded          += updateHandler;
            TaskService.Errors.TasksRemoved        += updateHandler;
            BrandingService.ApplicationNameChanged += ApplicationNameChanged;

            AddSubview(buildResults);
            AddSubview(imageView);
            AddSubview(textField);

            progressView = new ProgressView();
            AddSubview(progressView);
        }
Example #38
0
        public StatusBar()
        {
            AllowsEditingTextAttributes = Selectable = Editable = false;

            textField.Cell             = new VerticallyCenteredTextFieldCell(yOffset: -0.5f);
            textField.Cell.StringValue = "";
            textField.Cell.PlaceholderAttributedString = GetStatusString(BrandingService.ApplicationName, NSColor.DisabledControlText);

            // The rect is empty because we use InVisibleRect to track the whole of the view.
            textFieldArea = new NSTrackingArea(CGRect.Empty, NSTrackingAreaOptions.MouseEnteredAndExited | NSTrackingAreaOptions.ActiveInKeyWindow | NSTrackingAreaOptions.InVisibleRect, this, null);
            textField.AddTrackingArea(textFieldArea);

            imageView.Image = ImageService.GetIcon(Stock.StatusSteady).ToNSImage();

            buildResults        = new BuildResultsView();
            buildResults.Hidden = true;
            AddSubview(buildResults);

            // Fixes a render glitch of a whiter bg than the others.
            if (MacSystemInformation.OsVersion >= MacSystemInformation.Yosemite)
            {
                BezelStyle = NSTextFieldBezelStyle.Rounded;
            }

            WantsLayer         = true;
            Layer.CornerRadius = MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan ? 6 : 4;
            ctxHandler         = new StatusBarContextHandler(this);

            updateHandler = delegate {
                int ec = 0, wc = 0;

                foreach (var t in TaskService.Errors)
                {
                    if (t.Severity == TaskSeverity.Error)
                    {
                        ec++;
                    }
                    else if (t.Severity == TaskSeverity.Warning)
                    {
                        wc++;
                    }
                }

                Runtime.RunInMainThread(delegate {
                    buildResults.Hidden      = (ec == 0 && wc == 0);
                    buildResults.ResultCount = ec > 0 ? ec : wc;

                    buildImageId           = ec > 0 ? "md-status-error-count" : "md-status-warning-count";
                    buildResults.IconImage = ImageService.GetIcon(buildImageId, Gtk.IconSize.Menu).ToNSImage();

                    RepositionStatusIcons();
                });
            };

            updateHandler(null, null);

            TaskService.Errors.TasksAdded   += updateHandler;
            TaskService.Errors.TasksRemoved += updateHandler;

            AddSubview(imageView);
            AddSubview(textField);
        }