Exemplo n.º 1
0
    public void Init()
    {
        //_StartProfileOptimization();

        Title = App.AppNameLong;         //don't append document name etc

        if (App.Settings.wndpos.main == null)
        {
            Width  = 1000;
            Height = 700;
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            //and will EnsureInScreen
        }
        WndSavedRect.Restore(this, App.Settings.wndpos.main, o => App.Settings.wndpos.main = o);

        Panels.LoadAndCreateToolbars();

        App.Commands = new KMenuCommands(typeof(Menus), Panels.Menu);

        App.Commands[nameof(Menus.File.New)].SubmenuOpened       = (o, _) => FilesModel.FillMenuNew(o as MenuItem);
        App.Commands[nameof(Menus.File.Workspace)].SubmenuOpened = (o, _) => FilesModel.FillMenuRecentWorkspaces(o as MenuItem);

        var atb = new ToolBar[7] {
            Panels.THelp, Panels.TTools, Panels.TFile, Panels.TRun, Panels.TEdit, Panels.TCustom1, Panels.TCustom2
        };

        App.Commands.InitToolbarsAndCustomize(folders.ThisAppBS + @"Default\Commands.xml", AppSettings.DirBS + "Commands.xml", atb);

        var bRun = App.Commands[nameof(Menus.Run.Run_script)].FindButtonInToolbar(Panels.TRun);

        if (bRun != null)
        {
            bRun.Width = 50; bRun.Margin = new(10, 0, 10, 0);
        }                                                                               //make Run button bigger //SHOULDDO: bad if vertical toolbar

        var bNew = App.Commands[nameof(Menus.File.New)].FindMenuButtonInToolbar(Panels.TFile);

        if (bNew != null)
        {
            bNew.MouseDoubleClick += (_, e) => { e.Handled = true; Menus.File.New.New_script(); }
        }
        ;

        Panels.CreatePanels();

        App.Commands.BindKeysTarget(this, "");

        Panels.PanelManager.Container = g => { this.Content = g; };


        //timer.after(100, _ => DOptions.ZShow());
        //timer.after(100, _ => App.Model.Properties());
        //timer.after(100, _ => Menus.File.Workspace.New_workspace());
        //timer.after(100, _ => DIcons.ZShow());
        //timer.after(600, _ => Au.Tools.Dwnd.Dialog(wnd.find(null, "Shell_TrayWnd")));
        //timer.after(600, _ => Au.Tools.Dwnd.Dialog(wnd.findOrRun(null, "Notepad", run: () => run.it(folders.System + "notepad.exe"))));
        //timer.after(500, _ => Au.Tools.Delm.Dialog(new POINT(806, 1580)));
        //timer.after(500, _ => Au.Tools.Delm.Dialog());
        //timer.after(400, _ => Au.Tools.Duiimage.Dialog());
        //timer2.every(200, _ => { GC.Collect(); });

#if DEBUG
        App.Timer1s += () => {
            var e = Keyboard.FocusedElement as FrameworkElement;
            Debug_.PrintIf(e != null && !e.IsVisible, "focused invisible");
            //print.it(e, FocusManager.GetFocusedElement(App.Wmain));
        };
#endif
    }