示例#1
0
        public Form_engine()
        {
            InitializeComponent();
            m_theForm   = this;
            m_trayIcons = new List <NotifyIcon>();
            //m_privateClipboards = new ReadOnlyCollection<ClipData>[ControlItems.UC_clipboard.CLIPS_COUNT];
            m_privateTextClipboards = new string[ControlItems.UC_clipboard.CLIPS_COUNT];

            // create directory for storing configuration and gestures if it doesn't exists
            // otherwise nothing will be saved
            if (!System.IO.Directory.Exists(Config.Default.FilesLocation))
            {
                try { System.IO.Directory.CreateDirectory(Config.Default.FilesLocation); }
                catch { }
            }

            m_gestures = FileOptions.LoadGestures();
            List <PrgNamePath> whiteList, blackList, finalList;

            FileOptions.LoadLists(out whiteList, out blackList, out finalList);

            m_engine = new MyEngine();
            m_engine.LearntGestures = m_gestures;
            m_engine.Network.Curves = m_gestures.GetCurves();
            m_engine.Network.CheckParams();
            m_engine.AppStateChanged += new MyEngine.DlgAppStateChanged(AppStateChanged);
            m_engine.FinalList        = finalList;
            m_engine.SetImageList();
            m_engine.ApplySettings();
            Microsoft.Win32.SystemEvents.DisplaySettingsChanged += new EventHandler(SystemEvents_DisplaySettingsChanged);
            Microsoft.Win32.SystemEvents.PowerModeChanged       += new Microsoft.Win32.PowerModeChangedEventHandler(SystemEvents_PowerModeChanged);
            //RegistryEdit.SetWin7AntiBug();
            //RegistryEdit.RemWin7AntiBug();
            m_activeGestures = true;
            Translate();
        }
        private void AppStateChanged(bool active, MyEngine.AppState state, MyEngine.AppState realState)
        {

            if (m_closing // setting icon for closing form caused exception
                || m_pcSuspended) // if pc is about to suspend do not change the icon 
            {
                return;
            }

            Debug.WriteLine(string.Format("AppStateChanged - Active: {0}, State: {1}, RealState: {2} ", active, state, realState));
            Bitmap icon = Resources.logo16x16.ToBitmap();            
            Graphics g = Graphics.FromImage(icon);
            if (!active)
            {
                icon = MakeGrayscale(icon);
                g = Graphics.FromImage(icon);
                //Bitmap disabledIcon = new Bitmap(icon.Width, icon.Height);
                //Graphics gp = Graphics.FromImage(disabledIcon);
                //ControlPaint.DrawImageDisabled(gp, icon, 0, 0, Color.Transparent);
                //gp.Dispose();
                //icon = disabledIcon;
            }
            if (state == MyEngine.AppState.Autobehave)
                g.DrawImage(Resources.autobehave.ToBitmap(), new Point(0, 0));
            else if (state == MyEngine.AppState.Learning)
                g.DrawImage(Resources.clock.ToBitmap(), new Point(0, 0));
            g.Dispose();
            
            string text = "Just Gestures";
            
            if (realState == MyEngine.AppState.Learning)
                text += "\n(" + ST_tT_learning + ")";
            else if (realState == MyEngine.AppState.Autobehave)
                text += "\n(" + ST_tT_autobehave +")";
            else if (!active)
                text += "\n(" + ST_tT_disabled +")";
            //Debug.WriteLine("NotifyIcont Text: " + text);
            notifyIcon1.Text = text;
            notifyIcon1.Icon = Icon.FromHandle(icon.GetHicon());             
            
        }
        public Form_engine()
        {   
            InitializeComponent();
            m_theForm = this;
            m_trayIcons = new List<NotifyIcon>();
            //m_privateClipboards = new ReadOnlyCollection<ClipData>[ControlItems.UC_clipboard.CLIPS_COUNT];
            m_privateTextClipboards = new string[ControlItems.UC_clipboard.CLIPS_COUNT];

            // create directory for storing configuration and gestures if it doesn't exists
            // otherwise nothing will be saved 
            if (!System.IO.Directory.Exists(Config.Default.FilesLocation))
            {
                try { System.IO.Directory.CreateDirectory(Config.Default.FilesLocation); }
                catch { }
            }

            m_gestures = FileOptions.LoadGestures();
            List<PrgNamePath> whiteList, blackList, finalList;
            FileOptions.LoadLists(out whiteList, out blackList, out finalList);

            m_engine = new MyEngine();
            m_engine.LearntGestures = m_gestures;
            m_engine.Network.Curves = m_gestures.GetCurves();
            m_engine.Network.CheckParams();
            m_engine.AppStateChanged += new MyEngine.DlgAppStateChanged(AppStateChanged);
            m_engine.FinalList = finalList;
            m_engine.SetImageList();
            m_engine.ApplySettings();
            Microsoft.Win32.SystemEvents.DisplaySettingsChanged += new EventHandler(SystemEvents_DisplaySettingsChanged);
            Microsoft.Win32.SystemEvents.PowerModeChanged += new Microsoft.Win32.PowerModeChangedEventHandler(SystemEvents_PowerModeChanged);            
            //RegistryEdit.SetWin7AntiBug();
            //RegistryEdit.RemWin7AntiBug();
            m_activeGestures = true; 
            Translate();
        }