示例#1
0
            public static void LoadAll(Windawesome windawesome, 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("windawesome", windawesome);
                            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;
                    }
                }
            }
示例#2
0
        internal void LoadConfiguration(Windawesome windawesome)
        {
            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 or Ruby 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(windawesome, this, files);
        }
示例#3
0
        void IBar.InitializeBar(Windawesome windawesome)
        {
            // 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(windawesome); 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();
        }
示例#4
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);

                    windawesome = new Windawesome();
                    Application.Run(new WindawesomeApplicationContext());

                    Application.ThreadException -= OnApplicationThreadException;
                }
            }
        }
示例#5
0
        //private void Listen(Window window)
        //{
        //		if (window.titlebar == State.SHOWN || window.windowBorders == State.SHOWN)
        //		{
        //				NativeMethods.SendNotifyMessage(window.hWnd, START_WINDOW_PROC_MESSAGE, UIntPtr.Zero, IntPtr.Zero);
        //		}
        //		else if (window.titlebar == State.HIDDEN && window.windowBorders == State.HIDDEN)
        //		{
        //				NativeMethods.SendNotifyMessage(window.hWnd, STOP_WINDOW_PROC_MESSAGE, UIntPtr.Zero, IntPtr.Zero);
        //		}
        //		else if (window.titlebar == State.AS_IS || window.windowBorders == State.AS_IS)
        //		{
        //				var style = NativeMethods.GetWindowStyleLongPtr(window.hWnd);

        //				if ((style & NativeMethods.WS.WS_CAPTION) != 0 || (style & NativeMethods.WS.WS_SIZEBOX) != 0)
        //				{
        //						NativeMethods.SendNotifyMessage(window.hWnd, START_WINDOW_PROC_MESSAGE, UIntPtr.Zero, IntPtr.Zero);
        //				}
        //		}
        //}

        #region IPlugin Members

        void IPlugin.InitializePlugin(Windawesome windawesome)
        {
            Workspace.WorkspaceWindowAdded   += OnWorkspaceApplicationAdded;
            Workspace.WorkspaceWindowRemoved += OnWorkspaceApplicationRemoved;
            //Workspace.WorkspaceChangedFrom += OnWorkspaceChangedFrom;
            //Workspace.WorkspaceChangedTo += OnWorkspaceChangedTo;
            Workspace.WorkspaceLayoutChanged += OnWorkspaceLayoutChanged;
            this.windawesome = windawesome;

            subclassedWindows = new HashMultiSet <Window> [windawesome.config.Workspaces.Length];
            for (var i = 0; i < windawesome.config.Workspaces.Length; i++)
            {
                subclassedWindows[i] = new HashMultiSet <Window>();
            }
        }
示例#6
0
        void IWidget.StaticInitializeWidget(Windawesome windawesome)
        {
            // system tray hook
            if (NativeMethods.RegisterSystemTrayHook(windawesome.Handle))
            {
                if (SystemAndProcessInformation.isAtLeastVista && SystemAndProcessInformation.isRunningElevated)
                {
                    if (SystemAndProcessInformation.isAtLeast7)
                    {
                        NativeMethods.ChangeWindowMessageFilterEx(windawesome.Handle, NativeMethods.WM_COPYDATA, NativeMethods.MSGFLTEx.MSGFLT_ALLOW, IntPtr.Zero);
                    }
                    else
                    {
                        NativeMethods.ChangeWindowMessageFilter(NativeMethods.WM_COPYDATA, NativeMethods.MSGFLT.MSGFLT_ADD);
                    }
                }

                windawesome.RegisterMessage(NativeMethods.WM_COPYDATA, OnSystemTrayMessage);
            }
        }
示例#7
0
        void IWidget.StaticInitializeWidget(Windawesome windawesome)
        {
            if (NativeMethods.RegisterGlobalShellHook(windawesome.Handle))
            {
                globalShellHookMessage = NativeMethods.RegisterWindowMessage("GLOBAL_SHELL_HOOK");
                if (SystemAndProcessInformation.isAtLeastVista && SystemAndProcessInformation.isRunningElevated)
                {
                    if (SystemAndProcessInformation.isAtLeast7)
                    {
                        NativeMethods.ChangeWindowMessageFilterEx(windawesome.Handle, globalShellHookMessage, NativeMethods.MSGFLTEx.MSGFLT_ALLOW, IntPtr.Zero);
                    }
                    else
                    {
                        NativeMethods.ChangeWindowMessageFilter(globalShellHookMessage, NativeMethods.MSGFLT.MSGFLT_ADD);
                    }
                }

                windawesome.RegisterMessage((int)globalShellHookMessage, OnGlobalShellHookMessage);
            }
        }
示例#8
0
        void IPlugin.InitializePlugin(Windawesome windawesome)
        {
            this.windawesome = windawesome;

            if (logRuleMatching)
            {
                Windawesome.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;
            }
        }
示例#9
0
 void IWidget.StaticInitializeWidget(Windawesome windawesome)
 {
 }
示例#10
0
 void IPlugin.InitializePlugin(Windawesome windawesome)
 {
     windawesome.RegisterMessage(NativeMethods.WM_HOTKEY,
                                 (ref Message m) => registeredHotkeys[m.WParam.ToInt32()]());
 }
示例#11
0
 void IWidget.StaticInitializeWidget(Windawesome windawesome)
 {
     ApplicationTabsWidget.windawesome = windawesome;
 }
示例#12
0
 public void StaticInitializeWidget(Windawesome windawesome)
 {
 }
示例#13
0
 void IWidget.StaticInitializeWidget(Windawesome windawesome)
 {
     WorkspacesWidget.windawesome = windawesome;
 }
示例#14
0
 void IPlugin.InitializePlugin(Windawesome windawesome)
 {
 }