Пример #1
0
 public abstract void Execute(TodoOutput pad);
Пример #2
0
 public override void Execute(TodoOutput pad)
 {
     pad.UnsafeAddText(list);
 }
Пример #3
0
 public abstract void Execute(TodoOutput pad);
Пример #4
0
 public override void Execute(TodoOutput pad)
 {
     pad.UnsafeAddText(list);
 }
Пример #5
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();
    }