Beispiel #1
0
        void IPlugin.InitializePlugin(Dawsome dawsome)
        {
            this.dawsome = dawsome;

            if (logRuleMatching)
            {
                Dawsome.ProgramRuleMatched += OnProgramRuleMatched;
            }
            if (logCreation)
            {
                Workspace.WorkspaceWindowAdded += OnWorkspaceWindowAdded;
            }
            if (logDeletion)
            {
                Workspace.WorkspaceWindowRemoved += OnWorkspaceWindowRemoved;
            }
            if (logWorkspaceSwitching)
            {
                Workspace.WorkspaceShown += OnWorkspaceShown;
                Workspace.WorkspaceHidden += OnWorkspaceHidden;
                Workspace.WorkspaceActivated += OnWorkspaceActivated;
                Workspace.WorkspaceDeactivated += OnWorkspaceDeactivated;
            }
            if (logWindowMinimization)
            {
                Workspace.WorkspaceWindowMinimized += OnWorkspaceWindowMinimized;
            }
            if (logWindowRestoration)
            {
                Workspace.WorkspaceWindowRestored += OnWorkspaceWindowRestored;
            }
            if (logActivation)
            {
                Workspace.WindowActivatedEvent += OnWindowActivated;
            }
        }
Beispiel #2
0
        static void Main()
        {
            bool createdNew;
            using (new Mutex(true, "{BCDA45B7-407E-43F3-82FB-D1F6D6D093FF}", out createdNew))
            {
                if (createdNew) // if the mutex was taken successfully, i.e. this is the first instance of the app running
                {
                    SetPriorities();

                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    // set exception handling
                    Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                    Application.ThreadException += OnApplicationThreadException;
                    AppDomain.CurrentDomain.UnhandledException += (_, e) => OnException(e.ExceptionObject as Exception);

                    dawsome = new Dawsome();
                    Application.Run(new DawsomeApplicationContext());

                    Application.ThreadException -= OnApplicationThreadException;
                }
            }
        }
Beispiel #3
0
 void IWidget.StaticInitializeWidget(Dawsome dawsome)
 {
     WorkspacesWidget.dawsome = dawsome;
 }
Beispiel #4
0
 void IWidget.StaticInitializeWidget(Dawsome dawsome)
 {
 }
Beispiel #5
0
        void IBar.InitializeBar(Dawsome dawsome)
        {
            // statically initialize all widgets
            // this statement uses the laziness of Where
            this.leftAlignedWidgets.Cast<IWidget>().Concat(this.rightAlignedWidgets).Concat(this.middleAlignedWidgets).
                Where(w => !widgetTypes.Contains(w.GetType())).
                ForEach(w => { w.StaticInitializeWidget(dawsome); widgetTypes.Add(w.GetType()); });

            WidgetControlsChanged = OnWidgetControlsChanged;
            SpanWidgetControlsAdded = OnSpanWidgetControlsAdded;
            SpanWidgetControlsRemoved = OnSpanWidgetControlsRemoved;
            FixedWidthWidgetWidthChanged = OnFixedWidthWidgetWidthChanged;

            leftAlignedWidgets.ForEach(w => w.InitializeWidget(this));
            rightAlignedWidgets.ForEach(w => w.InitializeWidget(this));
            middleAlignedWidgets.ForEach(w => w.InitializeWidget(this));

            // get initial controls
            this.form.SuspendLayout();

            this.leftAlignedWidgets.SelectMany(widget => widget.GetInitialControls(true)).ForEach(this.form.Controls.Add);
            this.rightAlignedWidgets.SelectMany(widget => widget.GetInitialControls(false)).ForEach(this.form.Controls.Add);
            this.middleAlignedWidgets.SelectMany(widget => widget.GetInitialControls()).ForEach(this.form.Controls.Add);

            this.form.ResumeLayout();
        }
Beispiel #6
0
        void IWidget.StaticInitializeWidget(Dawsome dawsome)
        {
            if (NativeMethods.RegisterGlobalShellHook(dawsome.Handle))
            {
                globalShellHookMessage = NativeMethods.RegisterWindowMessage("GLOBAL_SHELL_HOOK");
                if (SystemAndProcessInformation.isAtLeastVista && SystemAndProcessInformation.isRunningElevated)
                {
                    if (SystemAndProcessInformation.isAtLeast7)
                    {
                        NativeMethods.ChangeWindowMessageFilterEx(dawsome.Handle, globalShellHookMessage, NativeMethods.MSGFLTEx.MSGFLT_ALLOW, IntPtr.Zero);
                    }
                    else
                    {
                        NativeMethods.ChangeWindowMessageFilter(globalShellHookMessage, NativeMethods.MSGFLT.MSGFLT_ADD);
                    }
                }

                dawsome.RegisterMessage((int) globalShellHookMessage, OnGlobalShellHookMessage);
            }
        }
Beispiel #7
0
 void IWidget.StaticInitializeWidget(Dawsome dawsome)
 {
     ApplicationTabsWidget.dawsome = dawsome;
 }
Beispiel #8
0
            public static void LoadAll(Dawsome dawsome, Config config, IEnumerable<FileInfo> files)
            {
                ScriptScope scope = null;
                ScriptEngine previousLanguage = null;
                foreach (var file in files)
                {
                    var engine = GetEngineForFile(file);
                    if (engine != null)
                    {
                        if (scope == null)
                        {
                            scope = engine.CreateScope();
                            scope.SetVariable("dawsome", dawsome);
                            scope.SetVariable("config", config);
                        }
                        else if (previousLanguage != engine)
                        {
                            var oldScope = scope;
                            scope = engine.CreateScope();
                            oldScope.GetItems().
                                Where(variable => variable.Value != null).
                                ForEach(variable => scope.SetVariable(variable.Key, variable.Value));
                            previousLanguage.Runtime.Globals.GetItems().
                                Where(variable => variable.Value != null).
                                ForEach(variable => scope.SetVariable(variable.Key, variable.Value));
                        }

                        scope = engine.ExecuteFile(file.FullName, scope);
                        previousLanguage = engine;
                    }
                }
            }
Beispiel #9
0
        internal void LoadConfiguration(Dawsome dawsome)
        {
            const string layoutsDirName = "Layouts";
            const string widgetsDirName = "Widgets";
            const string pluginsDirName = "Plugins";
            const string configDirName  = "Config";

            if (!Directory.Exists(configDirName) || Directory.EnumerateFiles(configDirName).FirstOrDefault() == null)
            {
                throw new Exception("You HAVE to have a " + configDirName + " directory in the folder and it must " +
                    "contain at least one Python file that initializes all instance variables in 'config' " +
                    "that don't have default values!");
            }
            if (!Directory.Exists(layoutsDirName))
            {
                Directory.CreateDirectory(layoutsDirName);
            }
            if (!Directory.Exists(widgetsDirName))
            {
                Directory.CreateDirectory(widgetsDirName);
            }
            if (!Directory.Exists(pluginsDirName))
            {
                Directory.CreateDirectory(pluginsDirName);
            }
            var files =
                Directory.EnumerateFiles(layoutsDirName).Select(fileName => new FileInfo(fileName)) .Concat(
                Directory.EnumerateFiles(widgetsDirName).Select(fileName => new FileInfo(fileName))).Concat(
                Directory.EnumerateFiles(pluginsDirName).Select(fileName => new FileInfo(fileName))).Concat(
                Directory.EnumerateFiles(configDirName) .Select(fileName => new FileInfo(fileName)));

            PluginLoader.LoadAll(dawsome, this, files);
        }
 void IPlugin.InitializePlugin(Dawsome dawsome)
 {
 }