Exemple #1
0
        public override void Start(AssetBuildContext context)
        {
            Context = context;
            try
            {
                Output.Clear();
                ErrorOutput.Clear();

                m_RunningProcess           = new Process();
                m_RunningProcess.StartInfo = StartInfo;

                // Enable async events
                m_RunningProcess.EnableRaisingEvents = true;
                m_RunningProcess.Exited             += new EventHandler(ExitHandler);
                m_RunningProcess.OutputDataReceived += new DataReceivedEventHandler(OnOutput);
                m_RunningProcess.ErrorDataReceived  += new DataReceivedEventHandler(OnErrorOutput);

                m_RunningProcess.Start();
                m_RunningProcess.BeginOutputReadLine();
                m_RunningProcess.BeginErrorReadLine();
            }
            catch (Exception exp)
            {
                ToolDebug.Error("Failed to run {0}, {1}", StartInfo.FileName, exp.Message);
                m_RunningProcess = null;
                // Log error.
            }
        }
Exemple #2
0
        /// <summary>
        /// Makes the GetData call to the base GLDAS class.
        /// </summary>
        /// <param name="errorMsg"></param>
        /// <param name="output"></param>
        /// <param name="input"></param>
        /// <returns></returns>S
        public ITimeSeriesOutput GetData(out string errorMsg, ITimeSeriesOutput output, ITimeSeriesInput input)
        {
            errorMsg = "";
            Data.Source.GLDAS gldas = new Data.Source.GLDAS();
            string            data  = gldas.GetData(out errorMsg, "PRECIP", input);
            //if (errorMsg.Contains("ERROR")) { return null; }
            //if (data.Contains("ERROR"))
            //{
            //    string[] lines = data.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
            //    errorMsg = lines[0] + " Dataset: precipitation; Source: " + input.Source;
            //    return null;
            //}

            ITimeSeriesOutput gldasOutput = output;

            if (errorMsg.Contains("ERROR"))
            {
                Utilities.ErrorOutput err = new ErrorOutput();
                output   = err.ReturnError("Precipitation", "gldas", errorMsg);
                errorMsg = "";
                return(output);
            }
            else
            {
                gldasOutput = gldas.SetDataToOutput(out errorMsg, "Precipitation", data, output, input);
            }

            gldasOutput = TemporalAggregation(out errorMsg, output, input);
            if (errorMsg.Contains("ERROR"))
            {
                return(null);
            }

            return(gldasOutput);
        }
Exemple #3
0
        public void InitalizePhysics()
        {
            // Construct engine objects
            this.Camera = new Camera(this);

            // Construct physics objects
            ErrorOutput errorOutput = new ErrorOutput();

            Foundation foundation = new Foundation(errorOutput);

            this.Physics = new Physics(foundation, checkRuntimeFiles: true);

            var sceneDesc = new SceneDesc()
            {
                Gravity = new Math.Vector3(0, -9.81f, 0)
            };

            this.Scene = this.Physics.CreateScene(sceneDesc);

            this.Scene.SetVisualizationParameter(VisualizationParameter.Scale, 2.0f);
            this.Scene.SetVisualizationParameter(VisualizationParameter.CollisionShapes, true);
            this.Scene.SetVisualizationParameter(VisualizationParameter.JointLocalFrames, true);
            this.Scene.SetVisualizationParameter(VisualizationParameter.JointLimits, true);
            this.Scene.SetVisualizationParameter(VisualizationParameter.ParticleSystemPosition, true);
            this.Scene.SetVisualizationParameter(VisualizationParameter.ActorAxes, true);

            // Connect to the remote debugger if it's there
            Physics.RemoteDebugger.Connect("localhost");

            CreateGroundPlane();
        }
Exemple #4
0
        public void InitalizePhysics()
        {
            // Construct engine objects
            this.Camera = new Camera(this);

            // Construct physics objects
            ErrorOutput errorOutput = new ErrorOutput();

            Foundation foundation = new Foundation(errorOutput);

            var pvd = new VisualDebugger.Pvd(foundation);

            this.Physics = new Physics(foundation, true, pvd);

            this.Scene = this.Physics.CreateScene(CreateSceneDesc(foundation));

            this.Scene.SetVisualizationParameter(VisualizationParameter.Scale, 2.0f);
            this.Scene.SetVisualizationParameter(VisualizationParameter.CollisionShapes, true);
            this.Scene.SetVisualizationParameter(VisualizationParameter.JointLocalFrames, true);
            this.Scene.SetVisualizationParameter(VisualizationParameter.JointLimits, true);
            this.Scene.SetVisualizationParameter(VisualizationParameter.ActorAxes, true);

            // Connect to the PhysX Visual Debugger (if the PVD application is running)
            this.Physics.Pvd.Connect("localhost");

            CreateGroundPlane();
        }
Exemple #5
0
    public float getNoise(Vector3 p, String channelName)
    {
        //Get the noise value at a certain point on a certain channel
        int channelID = -1;

        for (int n = 0; n < channel.Count; n++) //Convert channelName to channelID
        {
            if (channel[n].name == channelName)
            {
                channelID = n;
            }
        }
        if (channelID == -1)
        {
            ErrorOutput.error("The channel: \"" + channelName + "\" could not be found.");
            return(0.0f);
        }

        float result = getRawNoise(p, channelID);      //Calculate the noise value

        if (channel[channelID].edge == Edge.Sharp)     //If the edge is sharp check whether or not the value is above the threshold
        {
            if (result > channel[channelID].edge_threshold)
            {
                return(channel[channelID].max);
            }
            else
            {
                return(0.0f);
            }
        }
        return(result);
    }
Exemple #6
0
        private void Update()
        {
            string line;

            while (m_Commands.TryDequeue(out line))
            {
                CommandOutput?.Invoke(line);
                AnyOutput?.Invoke(line);
            }

            while (m_StandardOutput.TryDequeue(out line))
            {
                StandardOutput?.Invoke(line);
                AnyOutput?.Invoke(line);
            }

            while (m_ErrorOutput.TryDequeue(out line))
            {
                ErrorOutput?.Invoke(line);
                AnyOutput?.Invoke(line);
            }

            if (HasFinished)
            {
                EditorApplication.update -= Update;
                AssemblyReloadEvents.beforeAssemblyReload -= AssemblyReload;

                Completed?.Invoke(this);
            }
            ;
        }
        /// <summary>
        /// 使用<paramref name="pathString"/>配置路由中间件
        /// </summary>
        /// <param name="app"></param>
        /// <param name="pathString"></param>
        /// <returns></returns>
        public static IApplicationBuilder UseRoutingScanning(this IApplicationBuilder app, PathString pathString)
        {
            app.Map(pathString, build =>
            {
                var provider = build.ApplicationServices.GetService <IPathDescriptorProvider>();
                build.Run(async context =>
                {
                    object body;
                    if (context.Request.Method.Equals(HttpMethods.Get, StringComparison.OrdinalIgnoreCase))
                    {
                        var paths = provider.GetDescriptors();
                        body      = paths;
                        context.Response.ContentType = "application/json";
                    }
                    else
                    {
                        body = new ErrorOutput(SAE.CommonLibrary.StatusCodes.RequestInvalid);
                        context.Response.StatusCode = 400;
                    }

                    await context.Response.WriteAsync(body.ToJsonString());
                });
            });
            return(app);
        }
Exemple #8
0
        private void WriterTask(CancellationToken token)
        {
            while (!token.IsCancellationRequested || this.buffer.Count > 0)
            {
                if (this.buffer.TryTake(out DataRecord record))
                {
                    var failed = record.Parsed.Values.FirstOrDefault(x => x.IsFailed);
                    if (failed != null)
                    {
                        lock (this.buffer)
                        {
                            this.exceptionRecordCount++;
                            ErrorOutput.Write($"Line {record.RecordNumber} - Column {failed.Column.Name} - ");
                            ErrorOutput.WriteLine(string.Join(", ", record.Source));
                        }
                    }
                    else
                    {
                        foreach (var writer in this.writers)
                        {
                            writer.WriteLine(record.Parsed);
                        }

                        lock (this.buffer)
                        {
                            this.successfulRecordCount++;
                        }
                    }
                }
                else
                {
                    Thread.Sleep(50);
                }
            }
        }
        public void Given_There_Are_Errors_On_Inner_Execute__Expect_Errors_Transfered_To_Outer_Object()
        {
            //---------------Arrange-------------------
            var input = new RandomPersonInput
            {
                MinAge     = 19,
                MaxAge     = 19,
                ForceError = true
            };
            var useCase        = new GenerateRandomPersonUseCase();
            var outerPresenter = new PropertyPresenter <OuterTestObject, ErrorOutput>();
            var innerPresenter = new InterUseCasePresenter <OuterTestObject, InnerTestObject, ErrorOutput>();

            //---------------Act-------------------
            useCase.Execute(input, innerPresenter);
            innerPresenter.Render(x => new OuterTestObject
            {
                Age      = x.Age,
                FullName = $"{x.FirstName} {x.LastName}"
            }, outerPresenter);
            //---------------Assert-------------------
            var expected = new ErrorOutput();

            expected.AddError("Forced error happened");
            outerPresenter.ErrorContent.Should().BeEquivalentTo(expected);
        }
        private void Respond_With_Errors(IRespondWithSuccessOrError <IFileOutput, ErrorOutput> presenter,
                                         RenderedDocumentOutput output)
        {
            var errorOutput = new ErrorOutput();

            errorOutput.AddErrors(output.ErrorMessages);
            presenter.Respond(errorOutput);
        }
Exemple #11
0
 void OnErrorOutput(object sender, DataReceivedEventArgs e)
 {
     if (!String.IsNullOrEmpty(e.Data))
     {
         ToolDebug.Log("{0}: ", StartInfo.FileName, e.Data);
     }
     ErrorOutput.AppendFormat("{0}\r", e.Data);
 }
Exemple #12
0
 public PrEditRecord(IVEditRecord view, IVMain mainView, IModel model, IPrMain mainPresenter)
 {
     View          = view;
     MainView      = mainView;
     Model         = model;
     MainPresenter = mainPresenter;
     ErrHandler    = new ErrorOutput();
 }
 public static string ToHtml(this BaseCellOutput cell)
 {
     return(cell switch
     {
         DataOutput dataCell => convertDataToHtml(dataCell), //execute_result are also dataOutput
         ErrorOutput errCell => convertErrorToHtml(errCell),
         StreamOutput streamCell => convertStreamToHtml(streamCell),
         _ => throw new NotSupportedException(),
     });
Exemple #14
0
 /// <summary>
 /// Start the process synchronously, catch the exceptions
 /// </summary>
 public bool TryDoWait(bool hidden = false)
 {
     try {
         return(DoWait(hidden));
     } catch (Exception e) {
         ErrorOutput.AppendLine(e.Message);
         return(false);
     }
 }
            public void FetchErrors_WhenConstructed_ShouldReturnList()
            {
                //---------------Arrange-------------------
                //---------------Act-------------------
                var result = new ErrorOutput();

                //---------------Assert-------------------
                Assert.NotNull(result.Errors);
            }
            public void Given_Null_List_Of_Strings_Expect_Empty_List_Instead_Of_Null()
            {
                //---------------Arrange-------------------
                var errors = (List <string>)null;
                //---------------Act-------------------
                var result = new ErrorOutput(errors);

                //---------------Assert-------------------
                result.Errors.Should().NotBeNull();
            }
            public void HasErrors_WhenNoErrors_ShouldReturnFalse()
            {
                //---------------Arrange-------------------
                var errorOutputTo = new ErrorOutput();
                //---------------Act-------------------
                var result = errorOutputTo.HasErrors;

                //---------------Assert-------------------
                Assert.False(result);
            }
            public void Given_Null_String_Expect_Empty_List()
            {
                //---------------Arrange-------------------
                var error = (string)null;
                //---------------Act-------------------
                var result = new ErrorOutput(error);

                //---------------Assert-------------------
                result.Errors.Should().BeEmpty();
            }
            public void Given_Not_Null_String_Expect_It_Not_Added_To_Errors()
            {
                //---------------Arrange-------------------
                var error = "an error";
                var sut   = new ErrorOutput();

                //---------------Act-------------------
                sut.AddError(error);
                //---------------Assert-------------------
                sut.Errors.Should().Contain(error);
            }
            public void Given_Null_String_Expect_It_Not_Added_To_Errors()
            {
                //---------------Arrange-------------------
                var error = (string)null;
                var sut   = new ErrorOutput();

                //---------------Act-------------------
                sut.AddError(error);
                //---------------Assert-------------------
                sut.Errors.Should().BeEmpty();
            }
            public void HasErrors_WhenErrorsNull_ShouldReturnFalse()
            {
                //---------------Arrange-------------------
                var errorList     = (List <string>)null;
                var errorOutputTo = new ErrorOutput(errorList);
                //---------------Act-------------------
                var result = errorOutputTo.HasErrors;

                //---------------Assert-------------------
                Assert.False(result);
            }
            public void HasErrors_WhenErrors_ShouldReturnTrue()
            {
                //---------------Arrange-------------------
                var errorOutputTo = new ErrorOutput();

                errorOutputTo.AddError("test error");
                //---------------Act-------------------
                var result = errorOutputTo.HasErrors;

                //---------------Assert-------------------
                Assert.True(result);
            }
Exemple #23
0
        // Handle error message
        public static void ErrorMessage(string message, params object[] values)
        {
            //dout("ERROR: " + message, values);
            if (message == null || string.IsNullOrWhiteSpace(string.Format(message, values)))
            {
                return;                                                                                // don't print blank error lines
            }
            Trace.WriteLine(string.Format("ERROR: " + message, values));
            string timestamp = DateTime.Now.ToString("HH:mm:ss");

            ErrorOutput?.Invoke(new MessageArgs(string.Format(timestamp + " ERROR: " + message, values)));
        }
            public void GivenString_Expect_Message_Added()
            {
                //---------------Arrange-------------------
                var error = "an error";
                //---------------Act-------------------
                var result = new ErrorOutput(error);

                //---------------Assert-------------------
                result.Errors.Should().BeEquivalentTo(new List <string> {
                    error
                });
            }
Exemple #25
0
        protected void HandleError(Exception exception, ErrorOutput output)
        {
            var schedulerProviderException = exception as SchedulerProviderException;

            if (schedulerProviderException != null)
            {
                NameValueCollection properties = schedulerProviderException.SchedulerInitialProperties;
                output.ErrorDetails = properties
                                      .AllKeys
                                      .Select(key => new Property(key, properties.Get(key)))
                                      .ToArray();
            }
        }
Exemple #26
0
        public void ErrorContent_WhenErrors_ShouldReturnErrorTo()
        {
            //---------------Arrange-------------------
            var errors    = new ErrorOutput();
            var presenter = new PropertyPresenter <object, ErrorOutput>();

            presenter.Respond(errors);
            //---------------Act-------------------
            var result = presenter.ErrorContent;

            //---------------Assert-------------------
            Assert.Equal(errors, result);
        }
            public void Given_Not_Null_String_Expect_It_Added_To_Errors()
            {
                //---------------Arrange-------------------
                var error = "an error";
                var sut   = new ErrorOutput();

                //---------------Act-------------------
                sut.AddError(error);
                //---------------Assert-------------------
                sut.Errors.Should().BeEquivalentTo(new List <string> {
                    error
                });
            }
        public void Render_GivenErrorResponse_ShouldReturnUnprocessableEntityResultWithContent()
        {
            //---------------Arrange-------------------
            var content   = new ErrorOutput();
            var presenter = CreatePresenter();

            presenter.Respond(content);
            //---------------Act-------------------
            var result = presenter.Render() as UnprocessableEntityResult <ErrorOutput>;

            //---------------Assert-------------------
            Assert.NotNull(result);
            Assert.Equal(content, result.Value);
        }
            public void Given_List_Of_Strings_Expect_Message_Added()
            {
                //---------------Arrange-------------------
                var errors = new List <string>
                {
                    "error 1",
                    "error 2"
                };
                //---------------Act-------------------
                var result = new ErrorOutput(errors);

                //---------------Assert-------------------
                result.Errors.Should().BeEquivalentTo(errors);
            }
Exemple #30
0
 private void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e)
 {
     if (CancellationToken.IsCancellationRequested && !Process.HasExited)
     {
         Stop();
         return;
     }
     if (!string.IsNullOrEmpty(e.Data))
     {
         Debug(e.Data);
         ErrorOutput.Push(e.Data);
         OnError?.Invoke(e.Data);
     }
 }
Exemple #31
0
    //private bool statusSplash = false;
    /*bool update_status ()
     	{
         	statusSplash = splash.WaitingSplash;
         	return true;
     	}*/
    public MainWindow(string[] arguments)
        : base(Gtk.WindowType.Toplevel)
    {
        this.HeightRequest = this.Screen.Height;//-50;
        this.WidthRequest = this.Screen.Width;//-50;

        bool showSplash = true;
        bool openFileFromArg = false;
        string openFileAgument = "";
        for (int i = 0; i < arguments.Length; i++){
            Logger.LogDebugInfo("arg->{0}",arguments[i]);

            string arg = arguments[i];
            if (arg.StartsWith("-nosplash")){
                if (arg == "-nosplash")
                    showSplash = false;
            }
            if(!arg.EndsWith(".exe")){ // argument file msw
                if(File.Exists(arg)){
                    openFileAgument =arg;
                    if(arg.ToLower().EndsWith(".msw"))
                        openFileFromArg = true;
                }
            }
        }

        StringBuilder sbError = new StringBuilder();
        if(!File.Exists(MainClass.Settings.FilePath)){

            if(showSplash)
                splash = new SplashScreenForm(false);

            //statusSplash = true;
            Moscrif.IDE.Tool.Logger.LogDebugInfo(String.Format("Setting inicialize -{0}",DateTime.Now));
            string file = System.IO.Path.Combine(MainClass.Paths.SettingDir, "keybinding");
            if(MainClass.Platform.IsMac){
                Moscrif.IDE.Iface.KeyBindings.CreateKeyBindingsMac(file);
            } else{
                Moscrif.IDE.Iface.KeyBindings.CreateKeyBindingsWin(file);
            }
            MainClass.Settings.SaveSettings();

        } else {
            if(showSplash)
                splash = new SplashScreenForm(false);
        }

        if(MainClass.Platform.IsMac){
                ApplicationEvents.Quit += delegate (object sender, ApplicationQuitEventArgs e) {
                    Application.Quit ();
                    e.Handled = true;
                };

                ApplicationEvents.Reopen += delegate (object sender, ApplicationEventArgs e) {
                    MainClass.MainWindow.Deiconify ();
                    MainClass.MainWindow.Visible = true;
                    e.Handled = true;
                };
        }

        Moscrif.IDE.Tool.Logger.LogDebugInfo(String.Format("splash.show-{0}",DateTime.Now));
        Console.WriteLine(String.Format("splash.show-{0}",DateTime.Now));

        if(showSplash)
            splash.ShowAll();
        StockIconsManager.Initialize();
        Moscrif.IDE.Tool.Logger.LogDebugInfo(String.Format("mainwindow.build.start-{0}",DateTime.Now));
        Build();
        this.Maximize();

        Moscrif.IDE.Tool.Logger.LogDebugInfo(String.Format("mainwindow.build.end-{0}",DateTime.Now));

        this.llcLogin = new LoginLogoutControl();
        this.llcLogin.Events = ((Gdk.EventMask)(256));
        this.llcLogin.Name = "llcLogin";
        this.statusbar1.Add (this.llcLogin);
        Gtk.Box.BoxChild w14 = ((Gtk.Box.BoxChild)(this.statusbar1 [this.llcLogin]));
        w14.Position = 2;
        w14.Expand = false;
        w14.Fill = false;

        SetSettingColor();

        lblMessage1.Text="";
        lblMessage2.Text="";
        if (String.IsNullOrEmpty(MainClass.Paths.TempDir))
        {

            MessageDialogs md =
                new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("cannot_create_temp"),MainClass.Paths.TempDir, Gtk.MessageType.Error,null);
            md.ShowDialog();
            return;
        }
        string fullpath = MainClass.Paths.StylesDir;

        bool success = true;

        if (!Directory.Exists(fullpath))
            try {
                Directory.CreateDirectory(fullpath);
            } catch {
                success = false;
            }
        if (success){
            try {
                Mono.TextEditor.Highlighting.SyntaxModeService.LoadStylesAndModes(fullpath);
            } catch(Exception ex) {
                sbError.AppendLine("ERROR: " + ex.Message);
                Logger.Log(ex.Message);
            }
        }

        ActionUiManager.UI.AddWidget += new AddWidgetHandler(OnWidgetAdd);
        ActionUiManager.UI.ConnectProxy += new ConnectProxyHandler(OnProxyConnect);
        ActionUiManager.LoadInterface();
        this.AddAccelGroup(ActionUiManager.UI.AccelGroup);

        WorkspaceTree = new WorkspaceTree();
        FrameworkTree = new FrameworkTree();

        FileExplorer = new FileExplorer();

        FileNotebook.AppendPage(WorkspaceTree, new NotebookLabel("workspace-tree.png",MainClass.Languages.Translate("projects")));
        FileNotebook.BorderWidth = 2;

        FileNotebook.AppendPage(FrameworkTree, new NotebookLabel("libs.png",MainClass.Languages.Translate("libs")));
        FileNotebook.BorderWidth = 2;

        FileNotebook.AppendPage(FileExplorer, new NotebookLabel("workspace-tree.png",MainClass.Languages.Translate("files")));
        FileNotebook.BorderWidth = 2;

        FileNotebook.CurrentPage = 1;

        hpBodyMidle.Pack1(FileNotebook, false, true);
        hpRight = new HPaned();
        //hpRight.Fi

        hpRight.Pack1(EditorNotebook, true, true);
        hpRight.Pack2(PropertisNotebook, false, true);
        hpBodyMidle.Pack2(hpRight, true, true);
        FileNotebook.WidthRequest = 500;
        hpBodyMidle.ResizeMode = ResizeMode.Queue;

        try {
            ActionUiManager.SocetServerMenu();
            ActionUiManager.RecentAll(MainClass.Settings.RecentFiles.GetFiles(),
                                      MainClass.Settings.RecentFiles.GetProjects(),
                                                      MainClass.Settings.RecentFiles.GetWorkspace());
        } catch {
        }

        ddbProject = new DropDownButton();
        ddbProject.Changed+= OnChangedProject;
        ddbProject.WidthRequest = 175;
        ddbProject.SetItemSet(projectItems);

        ddbDevice = new DropDownButton();
        ddbDevice.Changed+= OnChangedDevice;
        ddbDevice.WidthRequest = 175;
        ddbDevice.SetItemSet(deviceItems);

        ddbResolution = new DropDownButton();
        ddbResolution.Changed+= OnChangedResolution;
        ddbResolution.WidthRequest = 175;
        ddbResolution.SetItemSet(resolutionItems);

        ReloadSettings(false);
        OpenFile("StartPage",false);

        PageIsChanged("StartPage");

        if ((MainClass.Settings.Account != null) && (MainClass.Settings.Account.Remember)){
            MainClass.User = MainClass.Settings.Account;
        } else {
            MainClass.User = null;
        }

        SetLogin();

        OutputConsole = new OutputConsole();

        Gtk.Menu outputMenu = new Gtk.Menu();
        GetOutputMenu(ref outputMenu);

        BookmarkOutput = new BookmarkOutput();

        OutputNotebook.AppendPage(OutputConsole, new NotebookMenuLabel("console.png",MainClass.Languages.Translate("console"),outputMenu));
        OutputNotebook.AppendPage(FindReplaceControl, new NotebookLabel("find.png",MainClass.Languages.Translate("find")));
        OutputNotebook.AppendPage(BookmarkOutput, new NotebookLabel("bookmark.png",MainClass.Languages.Translate("bookmarks")));

        LogMonitor = new LogMonitor();
        Gtk.Menu monMenu = new Gtk.Menu();
        GetOutputMenu(ref monMenu, LogMonitor);

        OutputNotebook.AppendPage(LogMonitor, new NotebookMenuLabel("log.png",MainClass.Languages.Translate("Monitor"),monMenu));

        LogGarbageCollector = new LogGarbageCollector();
        Gtk.Menu gcMenu = new Gtk.Menu();
        GetOutputMenu(ref gcMenu, LogGarbageCollector);

        garbageColectorLabel =new NotebookMenuLabel("garbage-collector.png",MainClass.Languages.Translate("garbage_collector",0),gcMenu);

        OutputNotebook.AppendPage(LogGarbageCollector,garbageColectorLabel );

        hpOutput.Add1(OutputNotebook);

        ProcessOutput = new ProcessOutput();
        Gtk.Menu taskMenu = new Gtk.Menu();
        GetOutputMenu(ref taskMenu, ProcessOutput);
        TaskNotebook.AppendPage(ProcessOutput, new NotebookMenuLabel("task.png",MainClass.Languages.Translate("process"),taskMenu));

        ErrorOutput = new ErrorOutput();
        Gtk.Menu errorMenu = new Gtk.Menu();
        GetOutputMenu(ref errorMenu, ErrorOutput);
        TaskNotebook.AppendPage(ErrorOutput, new NotebookMenuLabel("error.png",MainClass.Languages.Translate("errors"),errorMenu));

        LogOutput = new LogOutput();
        Gtk.Menu logMenu = new Gtk.Menu();
        GetOutputMenu(ref logMenu, LogOutput);
        TaskNotebook.AppendPage(LogOutput, new NotebookMenuLabel("log.png",MainClass.Languages.Translate("logs"),logMenu));

        TodoOutput = new TodoOutput();
        TaskNotebook.AppendPage(TodoOutput, new NotebookLabel("task.png",MainClass.Languages.Translate("task")));

        FindOutput = new FindOutput();
        Gtk.Menu findMenu = new Gtk.Menu();
        GetOutputMenu(ref findMenu, FindOutput);
        TaskNotebook.AppendPage(FindOutput, new NotebookMenuLabel("find.png",MainClass.Languages.Translate("find_result"),findMenu));

        hpOutput.Add2(TaskNotebook);
        FirstShow();

        EditorNotebook.PageIsChanged +=PageIsChanged;

        if (openFileFromArg){ // open workspace from argument file
         	Workspace workspace = Workspace.OpenWorkspace(openFileAgument);
            Console.WriteLine("Open File From Arg");
            if (workspace != null){
                ReloadWorkspace(workspace, false,false);
                Console.WriteLine("RecentFiles");
                MainClass.Settings.RecentFiles.AddWorkspace(workspace.FilePath, workspace.FilePath);
                ActionUiManager.RefreshRecentAll(MainClass.Settings.RecentFiles.GetFiles(),
                                      MainClass.Settings.RecentFiles.GetProjects(),
                                         MainClass.Settings.RecentFiles.GetWorkspace());
            } else
                openFileFromArg = false;
        } else if((MainClass.Settings.OpenLastOpenedWorkspace) && !openFileFromArg ){
            if(String.IsNullOrEmpty(MainClass.Workspace.FilePath) && (String.IsNullOrEmpty(MainClass.Settings.CurrentWorkspace) ) ){
                /*MessageDialogs md =
                new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("workspace_is_corrupted"), null, Gtk.MessageType.Error,null);
                    md.ShowDialog();*/
                MainClass.Settings.CurrentWorkspace = "";
            } else{
                ReloadWorkspace(MainClass.Workspace, false,false);
            }
        } else if(!MainClass.Settings.OpenLastOpenedWorkspace && (!openFileFromArg) ){
            MainClass.Workspace = new Workspace();
            MainClass.Settings.CurrentWorkspace = "";
        }

        if(!String.IsNullOrEmpty(openFileAgument)){
            if(!openFileAgument.ToLower().EndsWith(".msw"))
                OpenFile(openFileAgument,true);
        }

        EditorNotebook.Page=0;

        WorkspaceTree.FileIsSelected+= delegate(string fileName, int fileType,string appFileName) {

            if(String.IsNullOrEmpty(fileName)){
                SetSensitiveMenu(false);
                return;
            }
            ActionUiManager.SetSensitive("propertyall",true);

            SetSensitiveMenu(true);

            if(MainClass.Settings.AutoSelectProject){

                if((TypeFile)fileType == TypeFile.AppFile)
                    SetActualProject(fileName);
                else if (!String.IsNullOrEmpty(appFileName))
                    SetActualProject(appFileName);
            }//PropertisNotebook
            PropertisNotebook.RemovePage(0);
            if((TypeFile)fileType == TypeFile.SourceFile || ((TypeFile)fileType == TypeFile.StartFile )
               || ((TypeFile)fileType == TypeFile.ExcludetFile ) ){
                string file = "";
                string appfile = "";
                int typ = -1;
                Gtk.TreeIter ti = new Gtk.TreeIter();
                WorkspaceTree.GetSelectedFile(out file, out typ, out ti);

                if (String.IsNullOrEmpty(file))
                    return;

                appfile = WorkspaceTree.GetSelectedProjectApp();

                Project p = MainClass.Workspace.FindProject_byApp(appfile, true);
                if (p == null)
                    return;

                FilePropertisData fpd = new FilePropertisData();
                fpd.Filename = MainClass.Workspace.GetRelativePath(file);
                fpd.Project = p;

                FilePropertyWidget fpw = new FilePropertyWidget( fpd);
                PropertisNotebook.AppendPage(fpw,new Label("Properties"));

            }else  if ((TypeFile)fileType == TypeFile.Directory){

                string file = "";
                string appfile = "";
                int typ = -1;
                Gtk.TreeIter ti = new Gtk.TreeIter();
                WorkspaceTree.GetSelectedFile(out file, out typ, out ti);

                if (String.IsNullOrEmpty(file)) return;

                appfile = WorkspaceTree.GetSelectedProjectApp();

                Project p = MainClass.Workspace.FindProject_byApp(appfile, true);
                if (p == null)
                    return;

                FilePropertisData fpd = new FilePropertisData();
                fpd.Filename = MainClass.Workspace.GetRelativePath(file);
                fpd.Project = p;

                DirPropertyWidget fpw = new DirPropertyWidget( fpd);
                PropertisNotebook.AppendPage(fpw,new Label("Properties"));

            }else  if ((TypeFile)fileType == TypeFile.AppFile){

                string file = "";
                int typ = -1;
                Gtk.TreeIter ti = new Gtk.TreeIter();
                WorkspaceTree.GetSelectedFile(out file, out typ, out ti);

                if (String.IsNullOrEmpty(file)) return;

                Project p = MainClass.Workspace.FindProject_byApp(file, true);
                if (p == null)
                    return;

                ProjectPropertyWidget fpw = new ProjectPropertyWidget( p);
                PropertisNotebook.AppendPage(fpw,new Label("Properties"));

            } else{

            }
        };

        SetSensitiveMenu(false);

        string newUpdater = System.IO.Path.Combine(MainClass.Paths.AppPath,"moscrif-updater.exe.new");

        if(System.IO.File.Exists(newUpdater)){

            string oldUpdater = System.IO.Path.Combine(MainClass.Paths.AppPath,"moscrif-updater.exe");
            try{
                if(File.Exists(oldUpdater))
                    File.Delete(oldUpdater);

                  File.Copy(newUpdater,oldUpdater);

                  File.Delete(newUpdater);
            }catch(Exception ex){
                sbError.AppendLine("WARNING: " + ex.Message);
                Logger.Error(ex.Message);
            }
        }

        Gtk.Drag.DestSet (this, 0, null, 0);
        this.DragDrop += delegate(object o, DragDropArgs args) {

            Gdk.DragContext dc=args.Context;

            foreach (object k in dc.Data.Keys){
                Console.WriteLine(k);
            }
            foreach (object v in dc.Data.Values){
                Console.WriteLine(v);
            }

            Atom [] targets = args.Context.Targets;
            foreach (Atom a in targets){
                if(a.Name == "text/uri-list")
                    Gtk.Drag.GetData (o as Widget, dc, a, args.Time);
            }
        };

        this.DragDataReceived += delegate(object o, DragDataReceivedArgs args) {

            if(args.SelectionData != null){
                string fullData = System.Text.Encoding.UTF8.GetString (args.SelectionData.Data);

                foreach (string individualFile in fullData.Split ('\n')) {
                    string file = individualFile.Trim ();
                    if (file.StartsWith ("file://")) {
                        file = new Uri(file).LocalPath;

                        try {
                            OpenFile(file,true);
                        } catch (Exception e) {
                            sbError.AppendLine("ERROR: " + String.Format("unable to open file {0} exception was :\n{1}", file, e.ToString()));
                            Logger.Error(String.Format("unable to open file {0} exception was :\n{1}", file, e.ToString()));
                        }
                    }
                }
            }
        };
        //table1.Attach(ddbSocketIP,2,3,0,1,AttachOptions.Shrink,AttachOptions.Shrink,0,0);
        this.ShowAll();
        //this.Maximize();

        int x, y, w, h, d = 0;
        hpOutput.Parent.ParentWindow.GetGeometry(out x, out y, out w, out h, out d);
        hpOutput.Position = w / 2;

        //vpMenuRight.Parent.ParentWindow.GetGeometry(out x, out y, out w, out h, out d);
        tblMenuRight.Parent.ParentWindow.GetGeometry(out x, out y, out w, out h, out d);
        tblMenuRight.RowSpacing = 0;
        tblMenuRight.ColumnSpacing = 0;
        tblMenuRight.BorderWidth = 0;
        if(w<1200){
            //vpMenuRight.WidthRequest =125;
            tblMenuRight.WidthRequest =220;
        } else {
            if(MainClass.Platform.IsMac)
                tblMenuRight.WidthRequest =320;
            else
                tblMenuRight.WidthRequest =300;
        }

        if (MainClass.Platform.IsMac) {
            try{
                ActionUiManager.CreateMacMenu(mainMenu);

            } catch (Exception ex){
                sbError.AppendLine(String.Format("ERROR: Mac IGE Main Menu failed."+ex.Message));
                Logger.Error("Mac IGE Main Menu failed."+ex.Message,null);
            }
        }
        ReloadPanel();
        Moscrif.IDE.Tool.Logger.LogDebugInfo(String.Format("splash.hide-{0}",DateTime.Now));
        // Send message to close splash screen on win
        Console.WriteLine(String.Format("splash.hide-{0}",DateTime.Now));

        if(showSplash)
            splash.HideAll();

        EditorNotebook.OnLoadFinish = true;

        OutputConsole.WriteError(sbError.ToString());

        Moscrif.IDE.Iface.SocketServer.OutputClientChanged+= delegate(object sndr, string message) {
            Gtk.Application.Invoke(delegate{
                    this.OutputConsole.WriteText(message);
                    Console.WriteLine(message);
                });
        };

        Thread ExecEditorThreads = new Thread(new ThreadStart(ExecEditorThreadLoop));

        ExecEditorThreads.Name = "ExecEditorThread";
        ExecEditorThreads.IsBackground = true;
        ExecEditorThreads.Start();
        //LoadDefaultBanner();

        toolbarBanner = new Toolbar ();
        toolbarBanner.WidthRequest = 220;
        tblMenuRight.Attach(toolbarBanner,0,1,0,2,AttachOptions.Fill,AttachOptions.Expand|AttachOptions.Fill,0,0);

        bannerImage.WidthRequest = 200;
        bannerImage.HeightRequest = 40;

        toolbarBanner.Add(bannerImage);//(bannerButton);
        toolbarBanner.ShowAll();
        LoadDefaultBanner();

        //bannerImage.GdkWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Hand2);

        Thread BannerThread = new Thread(new ThreadStart(BannerThreadLoop));

        BannerThread.Name = "BannerThread";
        BannerThread.IsBackground = true;
        BannerThread.Start();
    }
 bool isValid(string x, ErrorOutput pos, bool addRoot)
 {
     if (addRoot)
     {
         x = string.Format("<root>{0}</root>", x);
     }
     using (var rdr = new XmlTextReader(new StringReader(x)))
     {
         try
         {
             while (rdr.Read())
             {
             }
             return true;
         }
         catch (Exception ex)
         {
             switch (pos)
             {
                 case ErrorOutput.TokenTemplate:
                     lblTemplateError.Text = (Localization.GetString("error.Text", LocalResourceFile) +
                                              ex.Message);
                     lblTemplateError.Visible = true;
                     break;
                 case ErrorOutput.XslTranformation:
                     lblXslScriptError.Text = (Localization.GetString("error.Text", LocalResourceFile) +
                                               ex.Message);
                     lblXslScriptError.Visible = true;
                     break;
                 case ErrorOutput.Save:
                     lblSaveXslError.Text = (Localization.GetString("error.Text", LocalResourceFile) + ex.Message);
                     lblSaveXslError.Visible = true;
                     break;
             }
             return false;
         }
     }
 }
Exemple #33
0
		public void InitalizePhysics()
		{
			// Construct engine objects
			this.Camera = new Camera(this);

			// Construct physics objects
			ErrorOutput errorOutput = new ErrorOutput();

			Foundation foundation = new Foundation(errorOutput);
			
			this.Physics = new Physics(foundation, checkRuntimeFiles: true);

#if GPU
			var cudaContext = new CudaContextManager(foundation);
#endif

			var sceneDesc = new SceneDesc()
			{
				Gravity = new Math.Vector3(0, -9.81f, 0),
#if GPU
				GpuDispatcher = cudaContext.GpuDispatcher
#endif
			};

			this.Scene = this.Physics.CreateScene(sceneDesc);

			this.Scene.SetVisualizationParameter(VisualizationParameter.Scale, 2.0f);
			this.Scene.SetVisualizationParameter(VisualizationParameter.CollisionShapes, true);
			this.Scene.SetVisualizationParameter(VisualizationParameter.JointLocalFrames, true);
			this.Scene.SetVisualizationParameter(VisualizationParameter.JointLimits, true);
			this.Scene.SetVisualizationParameter(VisualizationParameter.ParticleSystemPosition, true);
			this.Scene.SetVisualizationParameter(VisualizationParameter.ActorAxes, true);

			// Connect to the remote debugger if it's there
			if (this.Physics.RemoteDebugger != null)
			{
				this.Physics.RemoteDebugger.Connect("localhost");
			}

			CreateGroundPlane();
		}