Example #1
0
        public static void OnTimeOutput(object o, OutputArgs args)
        {
            SpinButton spinButton = o as SpinButton;

            spinButton.Text = MillisecondsToTimeText((int)spinButton.Value);
            args.RetVal     = 1;
        }
Example #2
0
        protected void OnOutput (object o, OutputArgs args)
        {
            SpinButtonEntry entry = (SpinButtonEntry) o;

            if (0 == entry.ValueAsInt) {
                entry.Text = "";
            } else {
                entry.Text = entry.ValueAsInt.ToString ();
            }
            args.RetVal = 1;
        }
Example #3
0
            public void HandleOutput(object o, OutputArgs args)
            {
                var h = Handler;

                if (h.NeedsFormat)
                {
                    var val    = h.Control.Adjustment.Value;
                    var format = h.CurrentFormatString;
                    var text   = format == null?val.ToString(h.CultureInfo) : val.ToString(format, h.CultureInfo);

                    h.Control.Text = text;
                    args.RetVal    = 1;
                    return;
                }
                args.RetVal = 0;
            }
Example #4
0
        /// <summary>
        /// 程序输出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="arg2"></param>
        private static void OutputAction(object sender, OutputArgs arg2)
        {
            var name       = arg2.JobName;
            var content    = arg2.OutputContent;
            var createTime = DateTime.Now;
            var log        = DataManager.Current.JobInfos.FirstOrDefault(c => c.Name == name)?.SbLog;
            var value      = string.Format("[{0}]{1}", createTime.ToString("yyyy-MM-dd hh:mm:ss"), content);

            App.Current.Dispatcher.Invoke((Action) delegate
            {
                log?.Add(value);
            });
            var fileName = name + ".log";

            OutputManager.AppendOutput(fileName, value + "\n");
        }
Example #5
0
        private void _sceneEditorTransformComponentOutputHandler(object o, OutputArgs outputArgs)
        {
            if (SceneEditorScene.SelectedElement == null)
            {
                _sceneEditorTransformComponentTranstateSpinX.Text = "";
                _sceneEditorTransformComponentTranstateSpinY.Text = "";
                _sceneEditorTransformComponentTranstateSpinZ.Text = "";

                _sceneEditorTransformComponentRotateSpinX.Text = "";
                _sceneEditorTransformComponentRotateSpinY.Text = "";
                _sceneEditorTransformComponentRotateSpinZ.Text = "";

                _sceneEditorTransformComponentScaleSpinX.Text = "";
                _sceneEditorTransformComponentScaleSpinY.Text = "";
                _sceneEditorTransformComponentScaleSpinZ.Text = "";

                outputArgs.RetVal = true;
            }

            outputArgs.RetVal = false;
        }
Example #6
0
        private void OnOutput (object o, OutputArgs args)
        {
            SpinButton entry = (SpinButton) o;

            if (0 == entry.ValueAsInt) {
                entry.Text = "";
            } else {
                entry.Text = entry.ValueAsInt.ToString ();
            }
            args.RetVal = 1;
        }
Example #7
0
		/* These functions are used by glade that gets them using reflection.
         * Therefore the warning that the function is not used is disabled.
         */
        #pragma warning disable 169

		private void OnUnitOutput(object o, OutputArgs args){
			SpinButton spin = (SpinButton) o;
			string text = spin.Value.ToString()+"mm";
			if(spin.Text != text)
				spin.Text = text;
			args.RetVal = 1;
		}
Example #8
0
        public ProcessResult RunProcess(Action <object, OutputArgs> outputDataReceivedAction, Action <object> errorDataReceivedAction = null, Action <object> exitDataReceivedAction = null)
        {
            DateTime Starttime;
            DateTime Endtime;
            var      status = 0;
            var      p      = new Process()
            {
                StartInfo =
                {
                    FileName               = scheduleInfo.AsmPath,
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    CreateNoWindow         = true,
                    Arguments              = scheduleInfo.Name,
                }
            };

            if (DataManager.Current.RunningJob.Contains(scheduleInfo.Name))
            {
                return(new ProcessResult()
                {
                    Status = status,
                    Name = scheduleInfo.Name
                });
            }
            DataManager.Current.RunningJob.Add(scheduleInfo.Name);
            JobInfoManager.Refresh();
            p.Start();
            Starttime = p.StartTime;

            p.OutputDataReceived += (o, e) =>
            {
                if (!string.IsNullOrEmpty(e.Data) && status == 0)
                {
                    var arg = new OutputArgs(e.Data, scheduleInfo.Name);
                    outputDataReceivedAction(e, arg);
                }
            };

            p.ErrorDataReceived += (o, e) =>
            {
                if (!string.IsNullOrEmpty(e.Data) && status == 0)
                {
                    var msg = ("--------------------程序异常!--------------------\n");
                    var arg = new OutputArgs(msg + e.Data, scheduleInfo.Name);
                    outputDataReceivedAction(e, arg);
                    p.EnableRaisingEvents = false;

                    status = -1;
                }
            };

            //当EnableRaisingEvents为true,进程退出时Process会调用下面的委托函数
            p.Exited += (o, e) =>
            {
                if (status == 0)
                {
                    var msg = ("--------------------程序执行完毕!--------------------\n");
                    var arg = new OutputArgs(msg, scheduleInfo.Name);
                    outputDataReceivedAction(e, arg);

                    status = 1;
                }
            };
            p.EnableRaisingEvents = true;
            p.BeginOutputReadLine();
            p.BeginErrorReadLine();
            p.WaitForExit();
            Endtime = p.ExitTime;
            p.Close();
            DataManager.Current.RunningJob.Remove(scheduleInfo.Name);

            switch (status)
            {
            case -1:
                Task.Run(() =>
                {
                    errorDataReceivedAction?.Invoke(scheduleInfo);
                });

                break;

            case 1:
                Task.Run(() =>
                {
                    exitDataReceivedAction?.Invoke(scheduleInfo);
                });
                break;

            case 0: break;

            default:
                break;
            }

            return(new ProcessResult()
            {
                Status = status,
                Endtime = Endtime,
                Starttime = Starttime,
                Name = scheduleInfo.Name
            });
        }
Example #9
0
		private void OnDescriptiveSpinButtonOutput(object o, OutputArgs args){
			if(Math.Round(((SpinButton)o).Value,4) == 0){
				((Entry)o).Text = "";
				args.RetVal = 1;
			}
			else args.RetVal = 0;
		}
Example #10
0
		private void OnWarrantyOutput(object o, OutputArgs args){
			SpinButton spin = (SpinButton) o;
			if(spin.Value < 0) {
				string text;
				text = "∞";
				if(spin.Text != text) spin.Text = text;
				args.RetVal = 1;
			}
			else OnRelativeTimeSpanOutput(o,args);
		}
Example #11
0
		private void OnRelativeTimeSpanOutput(object o, OutputArgs args){			
			SpinButton spin = (SpinButton) o;
			string text;
			
			if(spin.ValueAsInt == 0)
				text = "";
			else {
				RelativeTimeSpan span = new RelativeTimeSpan();
				span.Months = spin.ValueAsInt;
				text = span.ToString();
			}
			
			if(spin.Text != text) spin.Text = text;
			args.RetVal = 1;
		}
Example #12
0
	public static void OnTimeOutput (object o, OutputArgs args) {
		SpinButton spinButton = o as SpinButton;
		spinButton.Text = MillisecondsToTimeText((int)spinButton.Value);
		args.RetVal = 1;
	}