Exemplo n.º 1
0
        public void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            IsDisposed = true;

            if (CommandViewFactory != null)
            {
                CommandViewFactory.Dispose();
            }

            _config      = null;
            _parser      = null;
            _gestureView = null;
            _intentStore = null;
            _pathTracker = null;

            SupportedCommands.Clear();
            SupportedCommands  = null;
            CommandViewFactory = null;

            _form.Dispose();
            _form = null;

            //GC.Collect();
        }
Exemplo n.º 2
0
        public SettingsFormController(IConfig config, GestureParser parser,
                                      Win32MousePathTracker2 pathTracker, JsonGestureIntentStore intentStore,
                                      CanvasWindowGestureView gestureView, GlobalHotKeyManager hotkeyMgr)
        {
            _config      = config;
            _parser      = parser;
            _pathTracker = pathTracker;
            _intentStore = intentStore;
            _gestureView = gestureView;
            _hotkeyMgr   = hotkeyMgr;

            #region 初始化支持的命令和命令视图
            //Add Command Types
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(DoNothingCommand)), typeof(DoNothingCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(HotKeyCommand)), typeof(HotKeyCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(WebSearchCommand)), typeof(WebSearchCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(WindowControlCommand)), typeof(WindowControlCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(TaskSwitcherCommand)), typeof(TaskSwitcherCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(OpenFileCommand)), typeof(OpenFileCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(SendTextCommand)), typeof(SendTextCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(GotoUrlCommand)), typeof(GotoUrlCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(CmdCommand)), typeof(CmdCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(ScriptCommand)), typeof(ScriptCommand));

            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(PauseWGesturesCommand)), typeof(PauseWGesturesCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(ChangeAudioVolumeCommand)), typeof(ChangeAudioVolumeCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(AddToBacklistCommand)), typeof(AddToBacklistCommand));

            CommandViewFactory.Register <AddToBacklistCommand, GeneralNoParameterCommandView>();
            CommandViewFactory.Register <OpenFileCommand, OpenFileCommandView>();
            CommandViewFactory.Register <DoNothingCommand, GeneralNoParameterCommandView>();
            CommandViewFactory.Register <HotKeyCommand, HotKeyCommandView>();
            CommandViewFactory.Register <GotoUrlCommand, GotoUrlCommandView>();
            CommandViewFactory.Register <PauseWGesturesCommand, GeneralNoParameterCommandView>();
            CommandViewFactory.Register <WebSearchCommand, WebSearchCommandView>();
            CommandViewFactory.Register <WindowControlCommand, WindowControlCommandView>();
            CommandViewFactory.Register <CmdCommand, CmdCommandView>();
            CommandViewFactory.Register <SendTextCommand, SendTextCommandView>();
            CommandViewFactory.Register <TaskSwitcherCommand, TaskSwitcherCommandView>();
            CommandViewFactory.Register <ScriptCommand, ScriptCommandView>();
            CommandViewFactory.Register <ChangeAudioVolumeCommand, GeneralNoParameterCommandView>();
            #endregion

            #region Hotcorner
            SupportedHotCornerCommands.Add(NamedAttribute.GetNameOf(typeof(DoNothingCommand)), typeof(DoNothingCommand));
            SupportedHotCornerCommands.Add(NamedAttribute.GetNameOf(typeof(HotKeyCommand)), typeof(HotKeyCommand));
            SupportedHotCornerCommands.Add(NamedAttribute.GetNameOf(typeof(CmdCommand)), typeof(CmdCommand));

            HotCornerCommandViewFactory.Register <DoNothingCommand, GeneralNoParameterCommandView>();
            HotCornerCommandViewFactory.Register <HotKeyCommand, HotKeyCommandView>();
            HotCornerCommandViewFactory.Register <CmdCommand, CmdCommandView>();
            #endregion

            _form = new SettingsForm(this);
        }
Exemplo n.º 3
0
        public SettingsFormController(IConfig config, GestureParser parser,
                                      Win32MousePathTracker2 pathTracker, JsonGestureIntentStore intentStore,
                                      CanvasWindowGestureView gestureView)
        {
            _config      = config;
            _parser      = parser;
            _pathTracker = pathTracker;
            _intentStore = intentStore;
            _gestureView = gestureView;

            #region 初始化支持的命令和命令视图
            SupportedCommands  = new Dictionary <string, Type>();
            CommandViewFactory = new CommandViewFactory <CommandViewUserControl>()
            {
                EnableCaching = false
            };

            //Add Command Types
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(DoNothingCommand)), typeof(DoNothingCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(HotKeyCommand)), typeof(HotKeyCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(WebSearchCommand)), typeof(WebSearchCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(WindowControlCommand)), typeof(WindowControlCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(TaskSwitcherCommand)), typeof(TaskSwitcherCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(OpenFileCommand)), typeof(OpenFileCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(SendTextCommand)), typeof(SendTextCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(GotoUrlCommand)), typeof(GotoUrlCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(CmdCommand)), typeof(CmdCommand));

            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(PauseWGesturesCommand)), typeof(PauseWGesturesCommand));
            SupportedCommands.Add(NamedAttribute.GetNameOf(typeof(ChangeAudioVolumeCommand)), typeof(ChangeAudioVolumeCommand));



            CommandViewFactory.Register <OpenFileCommand, OpenFileCommandView>();
            CommandViewFactory.Register <DoNothingCommand, GeneralNoParameterCommandView>();
            CommandViewFactory.Register <HotKeyCommand, HotKeyCommandView>();
            CommandViewFactory.Register <GotoUrlCommand, GotoUrlCommandView>();
            CommandViewFactory.Register <PauseWGesturesCommand, GeneralNoParameterCommandView>();
            CommandViewFactory.Register <WebSearchCommand, WebSearchCommandView>();
            CommandViewFactory.Register <WindowControlCommand, WindowControlCommandView>();
            CommandViewFactory.Register <CmdCommand, CmdCommandView>();
            CommandViewFactory.Register <SendTextCommand, SendTextCommandView>();
            CommandViewFactory.Register <TaskSwitcherCommand, TaskSwitcherCommandView>();

            CommandViewFactory.Register <ChangeAudioVolumeCommand, GeneralNoParameterCommandView>();



            #endregion

            _form = new SettingsForm(this);
        }
Exemplo n.º 4
0
        private static void ConfigureComponents()
        {
            #region Create Components

            intentFinder = new Win32GestrueIntentFinder(intentStore);
            var pathTracker = new Win32MousePathTracker2();
            gestureParser = new GestureParser(pathTracker, intentFinder);

            gestureView = new CanvasWindowGestureView(gestureParser);

            componentsToDispose.Add(gestureParser);
            componentsToDispose.Add(gestureView);
            componentsToDispose.Add(pathTracker);
            #endregion

            #region pathTracker
            pathTracker.DisableInFullscreen             = config.Get(ConfigKeys.PathTrackerDisableInFullScreen, true);
            pathTracker.PreferWindowUnderCursorAsTarget = config.Get(ConfigKeys.PathTrackerPreferCursorWindow, false);
            pathTracker.TriggerButton            = (Win32MousePathTracker2.GestureTriggerButton)config.Get(ConfigKeys.PathTrackerTriggerButton, Win32MousePathTracker2.GestureTriggerButton.Right);
            pathTracker.InitialValidMove         = config.Get(ConfigKeys.PathTrackerInitialValidMove, 4);
            pathTracker.StayTimeout              = config.Get(ConfigKeys.PathTrackerStayTimeout, true);
            pathTracker.StayTimeoutMillis        = config.Get(ConfigKeys.PathTrackerStayTimeoutMillis, 500);
            pathTracker.InitialStayTimeout       = config.Get(ConfigKeys.PathTrackerInitialStayTimeout, true);
            pathTracker.InitialStayTimeoutMillis = config.Get(ConfigKeys.PathTrackerInitialStayTimoutMillis, 150);

            pathTracker.RequestPauseResume  += paused => menuItem_pause_Click(null, EventArgs.Empty);
            pathTracker.RequestShowHideTray += ToggleTrayIconVisibility;

            #endregion

            #region gestureView
            gestureView.ShowPath               = config.Get(ConfigKeys.GestureViewShowPath, true);
            gestureView.ShowCommandName        = config.Get(ConfigKeys.GestureViewShowCommandName, true);
            gestureView.ViewFadeOut            = config.Get(ConfigKeys.GestureViewFadeOut, true);
            gestureView.PathMainColor          = Color.FromArgb(config.Get(ConfigKeys.GestureViewMainPathColor, gestureView.PathMainColor.ToArgb()));
            gestureView.PathAlternativeColor   = Color.FromArgb(config.Get(ConfigKeys.GestureViewAlternativePathColor, gestureView.PathAlternativeColor.ToArgb()));
            gestureView.PathMiddleBtnMainColor = Color.FromArgb(config.Get(ConfigKeys.GestureViewMiddleBtnMainColor, gestureView.PathMiddleBtnMainColor.ToArgb()));
            #endregion


            #region GestureParser

            gestureParser.EnableHotCorners  = config.Get(ConfigKeys.GestureParserEnableHotCorners, true);
            gestureParser.Enable8DirGesture = config.Get(ConfigKeys.GestureParserEnable8DirGesture, true);

            #endregion
        }
Exemplo n.º 5
0
        private static void ConfigureComponents()
        {
            #region Create Components

            intentFinder = new Win32GestrueIntentFinder(intentStore);
            var pathTracker = new Win32MousePathTracker2();
            gestureParser = new GestureParser(pathTracker, intentFinder);

            gestureView = new CanvasWindowGestureView(gestureParser);

            componentsToDispose.Add(gestureParser);
            componentsToDispose.Add(gestureView);
            componentsToDispose.Add(pathTracker);
            #endregion

            #region pathTracker
            //pathTracker.GestureButton = (Win32MousePathTracker2.GestureButtons)config.Get(ConfigKeys.PathTrackerGestureButton, 0);
            pathTracker.InitialValidMove         = config.Get(ConfigKeys.PathTrackerInitialValidMove, 4);
            pathTracker.StayTimeout              = config.Get(ConfigKeys.PathTrackerStayTimeout, true);
            pathTracker.StayTimeoutMillis        = config.Get(ConfigKeys.PathTrackerStayTimeoutMillis, 500);
            pathTracker.InitialStayTimeout       = config.Get(ConfigKeys.PathTrackerInitialStayTimeout, true);
            pathTracker.InitialStayTimeoutMillis = config.Get(ConfigKeys.PathTrackerInitialStayTimoutMillis, 150);

            pathTracker.RequestPauseResume += paused => menuItem_pause_Click(null, EventArgs.Empty);

            #endregion

            #region gestureView
            gestureView.ShowPath               = config.Get(ConfigKeys.GestureViewShowPath, true);
            gestureView.ShowCommandName        = config.Get(ConfigKeys.GestureViewShowCommandName, true);
            gestureView.ViewFadeOut            = config.Get(ConfigKeys.GestureViewFadeOut, true);
            gestureView.PathMainColor          = Color.FromArgb(config.Get(ConfigKeys.GestureViewMainPathColor, gestureView.PathMainColor.ToArgb()));
            gestureView.PathAlternativeColor   = Color.FromArgb(config.Get(ConfigKeys.GestureViewAlternativePathColor, gestureView.PathAlternativeColor.ToArgb()));
            gestureView.PathMiddleBtnMainColor = Color.FromArgb(config.Get(ConfigKeys.GestureViewMiddleBtnMainColor, gestureView.PathMiddleBtnMainColor.ToArgb()));

            #endregion


            #region GestureParser
            gestureParser.DisableInFullScreenMode = config.Get(ConfigKeys.GestureParserDisableInFullScreenMode, false);
            #endregion
        }
Exemplo n.º 6
0
        static void ConfigureComponents()
        {
            #region Create Components
            intentFinder = new Win32GestrueIntentFinder(intentStore);
            var pathTracker = new Win32MousePathTracker2();
            gestureParser = new GestureParser(pathTracker, intentFinder);

            gestureView = new CanvasWindowGestureView(gestureParser);

            componentsToDispose.Add(gestureParser);
            componentsToDispose.Add(gestureView);
            componentsToDispose.Add(pathTracker);
            componentsToDispose.Add(hotkeyMgr);
            #endregion

            #region pathTracker
            pathTracker.DisableInFullscreen             = config.Get(ConfigKeys.PathTrackerDisableInFullScreen, true);
            pathTracker.PreferWindowUnderCursorAsTarget = config.Get(ConfigKeys.PathTrackerPreferCursorWindow, false);
            pathTracker.TriggerButton             = (GestureTriggerButton)config.Get(ConfigKeys.PathTrackerTriggerButton, GestureTriggerButton.Right);
            pathTracker.InitialValidMove          = config.Get(ConfigKeys.PathTrackerInitialValidMove, 4);
            pathTracker.StayTimeout               = config.Get(ConfigKeys.PathTrackerStayTimeout, true);
            pathTracker.StayTimeoutMillis         = config.Get(ConfigKeys.PathTrackerStayTimeoutMillis, 500);
            pathTracker.InitialStayTimeout        = config.Get(ConfigKeys.PathTrackerInitialStayTimeout, true);
            pathTracker.InitialStayTimeoutMillis  = config.Get(ConfigKeys.PathTrackerInitialStayTimoutMillis, 150);
            pathTracker.RequestPauseResume       += paused => menuItem_pause_Click(null, EventArgs.Empty);
            pathTracker.EnableWindowsKeyGesturing = config.Get(ConfigKeys.EnableWindowsKeyGesturing, false);
            pathTracker.RequestShowHideTray      += ToggleTrayIconVisibility;

            #endregion

            #region gestureView
            gestureView.ShowPath               = config.Get(ConfigKeys.GestureViewShowPath, true);
            gestureView.ShowCommandName        = config.Get(ConfigKeys.GestureViewShowCommandName, true);
            gestureView.ViewFadeOut            = config.Get(ConfigKeys.GestureViewFadeOut, true);
            gestureView.PathMainColor          = Color.FromArgb(config.Get(ConfigKeys.GestureViewMainPathColor, gestureView.PathMainColor.ToArgb()));
            gestureView.PathAlternativeColor   = Color.FromArgb(config.Get(ConfigKeys.GestureViewAlternativePathColor, gestureView.PathAlternativeColor.ToArgb()));
            gestureView.PathMiddleBtnMainColor = Color.FromArgb(config.Get(ConfigKeys.GestureViewMiddleBtnMainColor, gestureView.PathMiddleBtnMainColor.ToArgb()));
            gestureView.PathXBtnMainColor      = Color.FromArgb(config.Get(ConfigKeys.GestureViewXBtnPathColor, gestureView.PathXBtnMainColor.ToArgb()));
            #endregion

            #region GestureParser
            gestureParser.EnableHotCorners  = config.Get(ConfigKeys.GestureParserEnableHotCorners, true);
            gestureParser.Enable8DirGesture = config.Get(ConfigKeys.GestureParserEnable8DirGesture, true);
            gestureParser.EnableRubEdge     = config.Get(ConfigKeys.GestureParserEnableRubEdges, true);

            #endregion
            //HOt key
            hotkeyMgr.HotKeyPreview      += HotkeyMgr_HotKeyPreview;
            hotkeyMgr.HotKeyRegistered   += HotkeyMgr_Updated;
            hotkeyMgr.HotKeyUnRegistered += HotkeyMgr_Updated;
            byte[] pauseHotKey = null;

            //workaround for bug introduced last version
            try { pauseHotKey = config.Get <byte[]>(ConfigKeys.PauseResumeHotKey, null); } catch (InvalidCastException e)
            {
                Debug.WriteLine(e);
            }

            if (pauseHotKey != null && pauseHotKey.Length > 0)
            {
                var hotkey = GlobalHotKeyManager.HotKey.FromBytes(pauseHotKey);

                try
                {
                    hotkeyMgr.RegisterHotKey(ConfigKeys.PauseResumeHotKey, hotkey, null);
                }catch (InvalidOperationException e)
                {
                    Debug.WriteLine(e);

                    //ignore for now ?
                }
            }
        }