Exemple #1
0
        /////////////////////////////////////////

        //internal class CoverControl : Control
        //{
        //	Label label;
        //	public CoverControl()
        //	{
        //		label = new Label() { Dock = DockStyle.Fill, TextAlign = ContentAlignment.MiddleCenter };
        //		Controls.Add( label );
        //		BackColor = Color.Black;
        //		Dock = DockStyle.Fill;
        //	}

        //	public void UpdateText( string text )
        //	{
        //		label.Text = text;
        //		Application.DoEvents();
        //	}
        //}

        /////////////////////////////////////////

        public EditorForm()
        {
            instance = this;

            //get CustomWindowsStyle project settings
            var customWindowsStyle = ProjectSettings.ReadParameterFromFile("CustomWindowsStyle");

            if (!string.IsNullOrEmpty(customWindowsStyle))
            {
                try
                {
                    KryptonToolkitSettings.AllowFormChrome = (bool)SimpleTypes.ParseValue(typeof(bool), customWindowsStyle);
                }
                catch { }
            }
            AllowFormChrome = KryptonToolkitSettings.AllowFormChrome;

            //if( /*showSplashScreenAtStartup &&*/ !Debugger.IsAttached )
            //{
            //	//Image image = MapEditor.Properties.Resources.MapEditorSplash;
            //	var splashForm = new SplashForm();// image );
            //	splashForm.Show();
            //}

            InitializeComponent();

            if (WinFormsUtility.IsDesignerHosted(this))
            {
                return;
            }

            ////!!!!new
            //buttonQATFormIntegration.Enabled = DWM.IsCompositionEnabled && AllowFormChrome;
            //allowFormChromeButton.Enabled = KryptonManager.AllowFormChrome;

            workspaceController = new WorkspaceControllerForForm(kryptonPanel, this);

            //EnableLocalization();

            EditorAssemblyInterface.Instance.InitializeWPFApplicationAndScriptEditor();
            //InitializeWPFApplication();
            //InitializeScriptEditor();

            //!!!!!тут?
            //QATButtonsInit();

            //apply editor settings
            EditorSettingsSerialization.Init();
            EditorFavorites.Init();
        }
Exemple #2
0
        /////////////////////////////////////////

        //internal class CoverControl : Control
        //{
        //	Label label;
        //	public CoverControl()
        //	{
        //		label = new Label() { Dock = DockStyle.Fill, TextAlign = ContentAlignment.MiddleCenter };
        //		Controls.Add( label );
        //		BackColor = Color.Black;
        //		Dock = DockStyle.Fill;
        //	}

        //	public void UpdateText( string text )
        //	{
        //		label.Text = text;
        //		Application.DoEvents();
        //	}
        //}

        /////////////////////////////////////////

        public EditorForm()
        {
            instance = this;

            //if( /*showSplashScreenAtStartup &&*/ !Debugger.IsAttached )
            //{
            //	//Image image = MapEditor.Properties.Resources.MapEditorSplash;
            //	var splashForm = new SplashForm();// image );
            //	splashForm.Show();
            //}

            InitializeComponent();

            if (EditorUtility.IsDesignerHosted(this))
            {
                return;
            }

            ////!!!!new
            //buttonQATFormIntegration.Enabled = DWM.IsCompositionEnabled && AllowFormChrome;
            //allowFormChromeButton.Enabled = KryptonManager.AllowFormChrome;

            workspaceController = new WorkspaceControllerForForm(kryptonPanel, this);

            EnableLocalization();

            EditorAssemblyInterface.Instance.InitializeWPFApplicationAndScriptEditor();
            //InitializeWPFApplication();
            //InitializeScriptEditor();

            //!!!!!тут?
            //QATButtonsInit();

            //apply editor settings
            EditorSettingsSerialization.Init();
            EditorFavorites.Init();
        }
Exemple #3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (EditorUtility.IsDesignerHosted(this))
            {
                return;
            }
            if (!loaded)
            {
                return;
            }

            //!!!!!slowly?

            //!!!!!!

            //if( needSelectResource != null )
            //{
            //	var selectResource = needSelectResource;
            //	needSelectResource = null;
            //	//ContentObjectSettings.Instance.SelectResource( selectResource );
            //}

            //UpdatePagesVisibility();

            //!!!!!
            //!!!!где еще вызывать?
            if (EngineApp.Instance != null)
            {
                EngineApp.DoTick();
            }

            if (EngineApp.GetSystemTime() - lastSlowUpdatingTime > 0.2 && !firstTick)
            {
                QATButtonsUpdate();
                RibbonUpdate();
                UpdateText();

                lastSlowUpdatingTime = EngineApp.GetSystemTime();
            }

            //save editor settings
            EditorSettingsSerialization.Dump();

            ScreenNotifications.Update();

            if (!needClose)
            {
                EditorAPI.SelectedDocumentWindowChangedUpdate();
            }

            if (!needClose)
            {
                foreach (var document in EditorAPI.Documents)
                {
                    document.EditorUpdateWhenDocumentModified_Tick();
                }
            }

            if (!needClose)
            {
                PreviewIconsManager.Update();
            }

            ////!!!!temp
            //CheckRestartApplicationToApplyChanged();

            if (!needClose)
            {
                UpdateSoundSystem();
            }

            //save editor settings
            if (!needClose)
            {
                KryptonAutoHiddenSlidePanel.Animate = ProjectSettings.Get.AnimateWindowsAutoHiding;
            }

            //if( !needClose )
            //	ScriptEditorEngine.Instance.UpdateSettings();

            UpdateVisibilityOfFloatingWindows();

            if (needClose)
            {
                needClose = false;
                Close();
            }

            if (firstTick)
            {
                //!!!!new
                firstTick = false;

                if (SplashForm.Instance != null)
                {
                    SplashForm.Instance.AllowClose = true;
                }

                // hide cover show ribbon.
                kryptonRibbon.Visible = true;

                if (coverControl != null)
                {
                    Controls.Remove(coverControl);
                }
                //coverControl.Visible = false;

                if (EditorSettingsSerialization.ShowTipsAsStartup)
                {
                    EditorAPI.ShowTips();
                }
            }

            canSaveConfig = true;
            firstTick     = false;
        }
Exemple #4
0
        private void EditorForm_Load(object sender, EventArgs e)
        {
            if (EditorUtility.IsDesignerHosted(this))
            {
                return;
            }

            //hide ribbon to avoid redrawing
            kryptonRibbon.Visible = false;

            // create cover
            coverControl           = new Control();
            coverControl.BackColor = Color.FromArgb(40, 40, 40);
            // 127, 127, 127 );
            //coverControl.BackColor = DarkTheme ? Color.FromArgb( 40, 40, 40 ) : Color.FromArgb( 42, 87, 154 );
            //coverControl.BackColor = Color.Black;
            coverControl.Dock = DockStyle.Fill;
            Controls.Add(coverControl);
            coverControl.BringToFront();
            Application.DoEvents();

            //dpi
            try
            {
                using (Graphics graphics = CreateGraphics())
                {
                    dpi = graphics.DpiX;
                }
            }
            catch (Exception ex)
            {
                dpi = 96;
                Log.Warning("EditorForm: CreateGraphics: Call failed. " + ex.Message);
            }

            kryptonRibbon.RibbonTabs.Clear();

            {
                EngineApp.InitSettings.UseApplicationWindowHandle = Handle;

                if (!EngineApp.Create())
                {
                    Log.Fatal("EngineApp.Create() failed.");
                    Close();
                    return;
                }

                //эксепшен не генегируется, просто падает

                //bool created = false;

                //if( Debugger.IsAttached )
                //	created = EngineApp.Create();
                //else
                //{
                //	try
                //	{
                //		//!!!!
                //		Log.Info( "dd" );

                //		created = EngineApp.Create();

                //		//!!!!
                //		Log.Info( "tt" );

                //	}
                //	catch( Exception e2 )
                //	{
                //		//!!!!
                //		Log.Info( "ee" );

                //		Log.FatalAsException( e2.ToString() );
                //	}
                //}

                //if( !created )
                //{
                //	Log.Fatal( "EngineApp.Create() failed." );
                //	Close();
                //	return;
                //}
            }

            EngineApp.DefaultSoundChannelGroup.Volume = 0;

            //set theme
            if (ProjectSettings.Get.Theme.Value == Component_ProjectSettings.ThemeEnum.Dark)
            {
                kryptonManager.GlobalPaletteMode = PaletteModeManager.NeoAxisBlack;
            }
            else
            {
                kryptonManager.GlobalPaletteMode = PaletteModeManager.NeoAxisBlue;
            }

            KryptonDarkThemeUtility.DarkTheme = EditorAPI.DarkTheme;
            if (EditorAPI.DarkTheme)
            {
                EditorAssemblyInterface.Instance.SetDarkTheme();
            }

            Aga.Controls.Tree.NodeControls.BaseTextControl.DarkTheme = EditorAPI.DarkTheme;

            //app button
            kryptonRibbon.RibbonAppButton.AppButtonText = EditorLocalization.Translate("AppButton", kryptonRibbon.RibbonAppButton.AppButtonText);
            if (DarkTheme)
            {
                kryptonRibbon.RibbonAppButton.AppButtonBaseColorDark  = Color.FromArgb(40, 40, 40);
                kryptonRibbon.RibbonAppButton.AppButtonBaseColorLight = Color.FromArgb(54, 54, 54);
            }

            //!!!! default editor layout:

            // IsSystemWindow = true for this:
            // для этих "системных" окон используется отдельная логика сериализации (окна создаются до загрузки конфига)
            // и отдельная логика закрытия (hide/remove)
            workspaceController.AddToDockspaceStack(new DockWindow[] { new ObjectsWindow(), new SettingsWindow() }, DockingEdge.Right);
            //workspaceController.AddDockspace(new MembersWindow(), "Members", DockingEdge.Right, new Size(300, 300));
            workspaceController.AddToDockspaceStack(new DockWindow[] { new ResourcesWindow(), new SolutionExplorer(), new PreviewWindow() }, DockingEdge.Left);
            workspaceController.AddToDockspace(new DockWindow[] { new MessageLogWindow(), new OutputWindow(), new DebugInfoWindow() }, DockingEdge.Bottom);

            //!!!!
            //workspaceController.AddDockWindow( new TipsWindow(), true, false );

            //!!!!эвент чтобы свои добавлять. и пример

            //load docking state
            {
                string configFile = VirtualPathUtility.GetRealPathByVirtual(dockingConfigFileName);
                //default settings
                if (!File.Exists(configFile))
                {
                    configFile = VirtualPathUtility.GetRealPathByVirtual(dockingConfigFileNameDefault);
                }

                if (File.Exists(configFile))
                {
                    //try
                    //{
                    ////!!!! If xml broken, we will not get an exception.
                    //// the exception is swallowed inside the krypton.
                    //// how do I know if an error has occurred?
                    workspaceController.LoadLayoutFromFile(configFile);
                    //}
                    //	catch
                    //	{
                    //		//!!!!TODO: layout broken. fix this!
                    //	}
                }
            }

            InitQAT();
            InitRibbon();

            UpdateText();

            //apply editor settings
            EditorSettingsSerialization.InitAfterFormLoad();

            XmlDocumentationFiles.PreloadBaseAssemblies();

            EditorAPI.SelectedDocumentWindowChanged += EditorAPI_SelectedDocumentWindowChanged;

            UpdateRecentProjectsInRegistry();

            LoginUtility.RequestFullLicenseInfo();

            loaded = true;
        }
Exemple #5
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (!IsHandleCreated || WinFormsUtility.IsDesignerHosted(this) || EditorAPI.ClosingApplication)
            {
                return;
            }
            if (!loaded)
            {
                return;
            }

            //!!!!!slowly?

            //!!!!!!

            //if( needSelectResource != null )
            //{
            //	var selectResource = needSelectResource;
            //	needSelectResource = null;
            //	//ContentObjectSettings.Instance.SelectResource( selectResource );
            //}

            //UpdatePagesVisibility();

            //!!!!!
            //!!!!где еще вызывать?
            if (EngineApp.Instance != null)
            {
                EngineApp.DoTick();
            }

            if (EngineApp.GetSystemTime() - lastSlowUpdatingTime > 0.2 && !firstTick)
            {
                QATButtonsUpdate();
                RibbonUpdate();
                UpdateText();

                lastSlowUpdatingTime = EngineApp.GetSystemTime();
            }

            //save editor settings
            EditorSettingsSerialization.Dump();

            ScreenNotifications.Update();

            if (!needClose)
            {
                EditorAPI.SelectedDocumentWindowChangedUpdate();
            }

            if (!needClose)
            {
                foreach (var document in EditorAPI.Documents)
                {
                    document.EditorUpdateWhenDocumentModified_Tick();
                }
            }

            //if( !needClose )
            //	PreviewImagesManager.Update();

            ////!!!!temp
            //CheckRestartApplicationToApplyChanged();

            if (!needClose)
            {
                UpdateSoundSystem();
            }

            //save editor settings
            if (!needClose)
            {
                KryptonAutoHiddenSlidePanel.Animate = ProjectSettings.Get.AnimateWindowsAutoHiding;
            }

            //if( !needClose )
            //	ScriptEditorEngine.Instance.UpdateSettings();

            UpdateVisibilityOfFloatingWindows();

            if (needClose)
            {
                needClose = false;
                Close();
            }

            //open file at startup
            if (firstTick && !needClose)
            {
                var realFileName = EditorSettingsSerialization.OpenFileAtStartup;
                EditorSettingsSerialization.OpenFileAtStartup = "";

                if (File.Exists(realFileName))
                {
                    //select new file in Resources window
                    EditorAPI.SelectFilesOrDirectoriesInMainResourcesWindow(new string[] { realFileName });

                    //open file
                    EditorAPI.OpenFileAsDocument(realFileName, true, true);
                }
            }

            if (firstTick)
            {
                firstTick = false;

                if (SplashForm.Instance != null)
                {
                    SplashForm.Instance.AllowClose = true;
                }

                // hide cover show ribbon.
                kryptonRibbon.Visible = true;

                if (coverControl != null)
                {
                    Controls.Remove(coverControl);
                }
                //coverControl.Visible = false;

                Invalidate(true);

                if (EditorSettingsSerialization.ShowTipsAsStartup)
                {
                    EditorAPI.ShowTips();
                }
            }

            if (unlockFormUpdateInTimer.HasValue && (DateTime.Now - unlockFormUpdateInTimer.Value).TotalSeconds > 0)
            {
                KryptonWinFormsUtility.LockFormUpdate(null);
                unlockFormUpdateInTimer = null;
            }

            if (!needClose)
            {
                EngineToolTipManager.Update();
            }

            canSaveConfig = true;
        }
Exemple #6
0
        private void EditorForm_Load(object sender, EventArgs e)
        {
            if (WinFormsUtility.IsDesignerHosted(this))
            {
                return;
            }

            //hide ribbon to avoid redrawing
            kryptonRibbon.Visible = false;

            // create cover
            coverControl           = new Control();
            coverControl.BackColor = Color.FromArgb(40, 40, 40);
            coverControl.Dock      = DockStyle.Fill;
            Controls.Add(coverControl);
            coverControl.BringToFront();
            Application.DoEvents();

            ////dpi
            //try
            //{
            //	using( Graphics graphics = CreateGraphics() )
            //	{
            //		dpi = graphics.DpiX;
            //	}
            //}
            //catch( Exception ex )
            //{
            //	dpi = 96;
            //	Log.Warning( "EditorForm: CreateGraphics: Call failed. " + ex.Message );
            //}

            kryptonRibbon.RibbonTabs.Clear();

            {
                EngineApp.InitSettings.UseApplicationWindowHandle = Handle;

                if (!EngineApp.Create())
                {
                    Log.Fatal("EngineApp.Create() failed.");
                    Close();
                    return;
                }

                //эксепшен не генегируется, просто падает

                //bool created = false;

                //if( Debugger.IsAttached )
                //	created = EngineApp.Create();
                //else
                //{
                //	try
                //	{
                //		//!!!!
                //		Log.Info( "dd" );

                //		created = EngineApp.Create();

                //		//!!!!
                //		Log.Info( "tt" );

                //	}
                //	catch( Exception e2 )
                //	{
                //		//!!!!
                //		Log.Info( "ee" );

                //		Log.FatalAsException( e2.ToString() );
                //	}
                //}

                //if( !created )
                //{
                //	Log.Fatal( "EngineApp.Create() failed." );
                //	Close();
                //	return;
                //}
            }

            EngineApp.DefaultSoundChannelGroup.Volume = 0;

            EnableLocalization();
            PreviewImagesManager.Init();

            //set theme
            if (ProjectSettings.Get.Theme.Value == Component_ProjectSettings.ThemeEnum.Dark)
            {
                kryptonManager.GlobalPaletteMode = PaletteModeManager.NeoAxisBlack;
            }
            else
            {
                kryptonManager.GlobalPaletteMode = PaletteModeManager.NeoAxisBlue;
            }

            KryptonDarkThemeUtility.DarkTheme = EditorAPI.DarkTheme;
            if (EditorAPI.DarkTheme)
            {
                EditorAssemblyInterface.Instance.SetDarkTheme();
            }
            Aga.Controls.Tree.NodeControls.BaseTextControl.DarkTheme = EditorAPI.DarkTheme;

            BackColor = EditorAPI.DarkTheme ? Color.FromArgb(40, 40, 40) : Color.FromArgb(240, 240, 240);

            //app button
            kryptonRibbon.RibbonAppButton.AppButtonText = EditorLocalization.Translate("AppButton", kryptonRibbon.RibbonAppButton.AppButtonText);
            if (DarkTheme)
            {
                kryptonRibbon.RibbonAppButton.AppButtonBaseColorDark  = Color.FromArgb(40, 40, 40);
                kryptonRibbon.RibbonAppButton.AppButtonBaseColorLight = Color.FromArgb(54, 54, 54);
            }

            //!!!! default editor layout:

            // IsSystemWindow = true for this:
            // для этих "системных" окон используется отдельная логика сериализации (окна создаются до загрузки конфига)
            // и отдельная логика закрытия (hide/remove)
            workspaceController.AddToDockspaceStack(new DockWindow[] { new ObjectsWindow(), new SettingsWindow() }, DockingEdge.Right);
            //workspaceController.AddDockspace(new MembersWindow(), "Members", DockingEdge.Right, new Size(300, 300));
            workspaceController.AddToDockspaceStack(new DockWindow[] { new ResourcesWindow(), new SolutionExplorer(), new PreviewWindow() }, DockingEdge.Left);
            workspaceController.AddToDockspace(new DockWindow[] { new MessageLogWindow(), new OutputWindow(), new DebugInfoWindow() }, DockingEdge.Bottom);

            Log.Info("Use Log.Info(), Log.Warning() methods to write to the window. These methods can be used in the Player. Press '~' to open console of the Player.");
            OutputWindow.Print("Use OutputWindow.Print() method to write to the window. Unlike Message Log window, this window is not a list. Here you can add text in arbitrary format.\n");

            //!!!!эвент чтобы свои добавлять. и пример

            //load docking state
            {
                string configFile = VirtualPathUtility.GetRealPathByVirtual(dockingConfigFileName);
                //default settings
                if (!File.Exists(configFile))
                {
                    configFile = VirtualPathUtility.GetRealPathByVirtual(dockingConfigFileNameDefault);
                }

                if (File.Exists(configFile))
                {
                    //no try catch to save the ability to work with debugger. in case when error happens during loading one of documents

                    //try
                    //{
                    workspaceController.LoadLayoutFromFile(configFile);

                    //!!!!
                    //hack. unhide the page to load it correctly. after loading the page will hided
                    foreach (var page in workspaceController.DockingManager.Pages)
                    {
                        if (page.needHideAfterLoading)
                        {
                            page.needHideAfterLoading = false;

                            var window = page.GetDockWindow();
                            if (window != null)
                            {
                                workspaceController.SetDockWindowVisibility(window, false);
                            }
                        }
                    }

                    //}
                    //catch( Exception e2 )
                    //{
                    //	var text = $"Error loading docking settings.\n\n" + e2.Message;
                    //	Log.Warning( text );
                    //	EditorMessageBox.ShowWarning( text );
                    //}
                }
            }

            InitQAT();
            InitRibbon();

            UpdateText();

            //apply editor settings
            EditorSettingsSerialization.InitAfterFormLoad();

            XmlDocumentationFiles.PreloadBaseAssemblies();

            EditorAPI.SelectedDocumentWindowChanged += EditorAPI_SelectedDocumentWindowChanged;

            UpdateRecentProjectsInRegistry();

            LoginUtility.RequestFullLicenseInfo();

            kryptonRibbon.BeforeMinimizedModeChanged += KryptonRibbon_BeforeMinimizedModeChanged;
            kryptonRibbon.MinimizedModeChanged       += KryptonRibbon_MinimizedModeChanged;

            KryptonWinFormsUtility.editorFormStartTemporaryLockUpdateAction = delegate()
            {
                if (IsHandleCreated && !EditorAPI.ClosingApplication)
                {
                    KryptonWinFormsUtility.LockFormUpdate(this);
                    unlockFormUpdateInTimer = DateTime.Now + TimeSpan.FromSeconds(0.1);
                }
            };

            loaded = true;
        }