예제 #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _color = (Color)Application.Current.Resources["HighlightColor"];

            if (_currentPointPatterns != null)
            {
                imgGestureThumbnail.Source = GestureImage.CreateImage(_currentPointPatterns, new Size(65, 65), _color);
            }

            if (_oldGestureName == null)
            {
                NamedPipe.SendMessageAsync("StartTeaching", "GestureSignDaemon");
                Title = LocalizationProvider.Instance.GetTextValue("GestureDefinition.Title");
            }
            else
            {
                Title = LocalizationProvider.Instance.GetTextValue("GestureDefinition.Rename");
                txtGestureName.Text = _oldGestureName; //this.txtGestureName.Text

                DrawGestureTextBlock.Visibility = ResetButton.Visibility = StackUpGestureButton.Visibility = Visibility.Collapsed;

                txtGestureName.Focus();
                txtGestureName.SelectAll();
            }
        }
예제 #2
0
 private async void OverlayGestureButton_OnClick(object sender, RoutedEventArgs e)
 {
     if (await NamedPipe.SendMessageAsync("OverlayGesture", "GestureSignDaemon"))
     {
         Close();
     }
 }
예제 #3
0
        static void Main(string[] args)
        {
            using (NamedPipe pipe = NamedPipe.CreateClient("callmonitor", PipeDirection.PIPE_ACCESS_OUTBOUND))
            {
                if (pipe != null && pipe.IsConnected == true)
                {
                    Console.WriteLine("***********************************************");
                    Console.WriteLine("*                                             *");
                    Console.WriteLine("*        Unbelievable MonitorCommander!       *");
                    Console.WriteLine("*                                             *");
                    Console.WriteLine("***********************************************");

                    string cmdLine;
                    while (true)
                    {
                        cmdLine = Console.ReadLine();

                        pipe.WriteString(cmdLine);
                        pipe.WaitForPipeDrain();
                    }
                }
                else
                {
                    Console.WriteLine("fail to connected...");
                }
            }

            Console.WriteLine("Press key to exit...");
            Console.Read();
        }
예제 #4
0
        public void Close()
        {
            switch (ConnectionMode)
            {
            case Mode.SocketMode:
                mSocket.Close();
                mSocket = null;
                break;

            case Mode.SerialMode:
                mSerialPort.Close();
                mSerialPort = null;
                Running     = false;
                break;

            case Mode.PipeMode:
                if (mNamedPipe != null)
                {
                    mNamedPipe.Close();
                    mNamedPipe = null;
                }
                Running = false;

                break;
            }

            mMedium = null;
            if (mKdb != null)
            {
                mKdb.Close();
            }
            mKdb           = null;
            ConnectionMode = Mode.ClosedMode;
        }
        private void Initialize(string pipeName, bool client)
        {
            PipeName = pipeName;
            Client   = client;

            Deactivated = true;

            Pipe              = new NamedPipe(pipeName, !client);
            Pipe.OnConnected += () =>
            {
                Deactivated = false;

                var handler = OnPipeConnected;
                if (handler != null)
                {
                    handler();
                }
            };

            if (client)
            {
                Pipe.Connect();
            }
            else
            {
                _ = Pipe.TryAccept();
            }
        }
예제 #6
0
        private async Task EndCapture()
        {
            // Create points capture event args, to be used to send off to event subscribers or to simulate original Touch event
            PointsCapturedEventArgs pointsInformation = new PointsCapturedEventArgs(new List <List <Point> >(_pointsCaptured.Values));

            // Notify subscribers that capture has ended (draw end)
            OnCaptureEnded();
            State = CaptureState.Ready;

            if (_gestureTimeout)
            {
                _gestureTimeout = false;
                pointsInformation.GestureTimeout = true;
            }
            // Notify PointsCaptured event subscribers that points have been captured.
            //CaptureWindow GetGestureName
            OnBeforePointsCaptured(pointsInformation);

            if (pointsInformation.Cancel)
            {
                return;
            }

            if (pointsInformation.Delay)
            {
                _timeoutTimer.Interval = AppConfig.GestureTimeout;
                _timeoutTimer.Start();
            }
            else if (Mode == CaptureMode.Training && !(_pointsCaptured.Count == 1 && _pointsCaptured.Values.First().Count == 1))
            {
                if (StackUpGesture)
                {
                    StackUpGesture = false;
                }
                else
                {
                    _pointPatternCache.Clear();
                }
                _pointPatternCache.Add(new PointPattern(new List <List <Point> >(_pointsCaptured.Values)));

                var message = new Tuple <string, List <List <List <Point> > > >(GestureManager.Instance.GestureName, _pointPatternCache.Select(p => p.Points).ToList());
                if (!await NamedPipe.SendMessageAsync(message, "GestureSignControlPanel"))
                {
                    Mode = CaptureMode.Normal;
                }
            }

            // Fire recognized event if we found a gesture match, otherwise throw not recognized event
            if (GestureManager.Instance.GestureName != null)
            {
                OnGestureRecognized(new RecognitionEventArgs(GestureManager.Instance.GestureName, pointsInformation.Points, pointsInformation.FirstCapturedPoints, _pointsCaptured.Keys.ToList()));
            }
            //else
            //    OnGestureNotRecognized(new RecognitionEventArgs(pointsInformation.Points, pointsInformation.FirstCapturedPoints, _pointsCaptured.Keys.ToList()));

            OnAfterPointsCaptured(pointsInformation);

            _pointsCaptured.Clear();
        }
예제 #7
0
        static void Main()
        {
            bool createdNew;

            using (new Mutex(true, Constants.Daemon, out createdNew))
            {
                if (createdNew)
                {
                    Application.EnableVisualStyles();
                    //Application.SetCompatibleTextRenderingDefault(false);
                    try
                    {
                        Application.ThreadException     += Application_ThreadException;
                        Logging.LoggedExceptionOccurred += (o, e) => ShowException(e);
                        Logging.OpenLogFile();

                        if (!LocalizationProvider.Instance.LoadFromFile("Daemon"))
                        {
                            LocalizationProvider.Instance.LoadFromResource(Properties.Resources.en);
                        }

                        PointCapture.Instance.Load();
                        SynchronizationContext uiContext = SynchronizationContext.Current;
                        TriggerManager.Instance.Load();

                        GestureManager.Instance.Load(PointCapture.Instance);
                        ApplicationManager.Instance.Load(PointCapture.Instance);
                        // Create host control class and pass to plugins
                        HostControl hostControl = new HostControl()
                        {
                            _ApplicationManager = ApplicationManager.Instance,
                            _GestureManager     = GestureManager.Instance,
                            _PointCapture       = PointCapture.Instance,
                            _PluginManager      = PluginManager.Instance,
                            _TrayManager        = TrayManager.Instance
                        };
                        PluginManager.Instance.Load(hostControl, uiContext);
                        TrayManager.Instance.Load();

                        NamedPipe.Instance.RunNamedPipeServer(Constants.Daemon, new MessageProcessor(uiContext));

                        Application.ApplicationExit += Application_ApplicationExit;

                        Application.Run();
                    }
                    catch (Exception e)
                    {
                        Logging.LogException(e);
                        MessageBox.Show(e.ToString(), LocalizationProvider.Instance.GetTextValue("Messages.Error"),
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        Application.Exit();
                    }
                }
                else
                {
                    NamedPipe.SendMessageAsync(IpcCommands.StartControlPanel, Constants.Daemon, wait: false).Wait();
                }
            }
        }
예제 #8
0
 private async void Window_Closing(object sender, CancelEventArgs e)
 {
     //Non-renaming mode
     if (_oldGestureName == null)
     {
         await NamedPipe.SendMessageAsync("StopTraining", "GestureSignDaemon");
     }
 }
예제 #9
0
        private void SaveFile(object state)
        {
            bool notice = (bool)state;
            // Save application list
            bool flag = FileManager.SaveObject(
                _Applications, Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "GestureSign", "Actions.act"), true);

            if (flag && notice)
            {
                NamedPipe.SendMessageAsync("LoadApplications", "GestureSignDaemon");
            }
        }
예제 #10
0
        private STARTUPINFO InnerSetupInteractive()
        {
            var         stdin  = NamedPipe.Create("testIn", Constants.PipeMode.Bidirectional);
            var         stdout = NamedPipe.Create("testOut", Constants.PipeMode.Bidirectional);
            var         stderr = NamedPipe.Create("testErr", Constants.PipeMode.Bidirectional);
            STARTUPINFO si     = new STARTUPINFO();

            si.hStdError  = stderr.Handle;
            si.hStdInput  = stdin.Handle;
            si.hStdOutput = stdout.Handle;
            return(si);
        }
예제 #11
0
        public bool Setup()
        {
            // Setup the named pipes
            string pipeName = Guid.NewGuid().ToString();

            pipeServer = new NamedPipe(pipeName);
            pipeClient = new NamedPipe(pipeName);
            pipeServer.Start(false);
            pipeClient.Start(true);

            return(true);
        }
예제 #12
0
        private void SetupTrayIconAndTrayMenu()
        {
            _trayIcon = new NotifyIcon();
            _trayMenu = new ContextMenu();
            _disableGesturesMenuItem = new MenuItem();
            _controlPanelMenuItem    = new MenuItem();
            _exitGestureSignMenuItem = new MenuItem();

            // Tray Icon
            _trayIcon.ContextMenu  = _trayMenu;
            _trayIcon.Text         = "GestureSign";
            _trayIcon.DoubleClick += (o, e) => { TrayIcon_Click(o, (MouseEventArgs)e); };
            _trayIcon.Click       += (o, e) => { TrayIcon_Click(o, (MouseEventArgs)e); };
            _trayIcon.Icon         = Resources.normal_daemon;

            // Tray Menu
            _trayMenu.MenuItems.AddRange(new MenuItem[] { _disableGesturesMenuItem, new MenuItem("-"), _controlPanelMenuItem, new MenuItem("-"), _exitGestureSignMenuItem });
            _trayMenu.Name = "TrayMenu";
            //TrayMenu.Size = new Size(194, 82);
            //TrayMenu.Opened += (o, e) => { Input.TouchCapture.Instance.DisableTouchCapture(); };
            //TrayMenu.Closed += (o, e) => { Input.TouchCapture.Instance.EnableTouchCapture(); };

            // Disable Gestures Menu Item
            _disableGesturesMenuItem.Checked = false;
            //miDisableGestures.CheckOnClick = true;
            _disableGesturesMenuItem.Name = "DisableGesturesMenuItem";
            //miDisableGestures.Size = new Size(193, 22);
            _disableGesturesMenuItem.Text   = LocalizationProvider.Instance.GetTextValue("TrayMenu.Disable");
            _disableGesturesMenuItem.Click += (o, e) => { ToggleDisableGestures(); };


            // Control Panel Menu Item
            _controlPanelMenuItem.Name = "ControlPanel";
            //_controlPanelMenuItem.Size = new Size(193, 22);
            _controlPanelMenuItem.Text   = LocalizationProvider.Instance.GetTextValue("TrayMenu.ControlPanel");
            _controlPanelMenuItem.Click += (o, e) =>
            {
                StartControlPanel();
            };

            _exitGestureSignMenuItem.Name = "ExitGestureSign";
            //miExitGestureSign.Size = new Size(193, 22);
            _exitGestureSignMenuItem.Text   = LocalizationProvider.Instance.GetTextValue("TrayMenu.Exit");
            _exitGestureSignMenuItem.Click += async(o, e) =>
            {
                await NamedPipe.SendMessageAsync(IpcCommands.Exit, Constants.ControlPanel, wait : false);

                // try to fix exception 0xc0020001
                Application.DoEvents();
                Application.Exit();
            };
        }
예제 #13
0
        private static bool Connect()
        {
            try
            {
                if (_pipeClient == null)
                {
                    _pipeClient = new NamedPipeClientStream(".", TouchInputProvider, PipeDirection.InOut,
                                                            PipeOptions.Asynchronous, TokenImpersonationLevel.None);
                }

                int i = 0;
                for (; i != 10; i++)
                {
                    if (!NamedPipe.NamedPipeDoesNotExist(TouchInputProvider))
                    {
                        break;
                    }
                    Thread.Sleep(500);
                }
                if (i == 10)
                {
                    return(false);
                }
                _pipeClient.Connect(10);

                if (_binaryWriter == null)
                {
                    _binaryWriter = new BinaryWriter(_pipeClient);
                }

                ThreadPool.QueueUserWorkItem(delegate
                {
                    StreamReader sr = new StreamReader(_pipeClient);
                    while (true)
                    {
                        var result = sr.ReadLine();
                        if (result == null || result == "Exit")
                        {
                            break;
                        }
                    }
                    Application.Exit();
                });
                return(true);
            }
            catch (Exception e)
            {
                Logging.LogException(e);
                return(false);
            }
        }
예제 #14
0
        private void EndCapture()
        {
            // Create points capture event args, to be used to send off to event subscribers or to simulate original Point event
            PointsCapturedEventArgs pointsInformation = SourceDevice == Devices.TouchPad ?
                                                        new PointsCapturedEventArgs(_pointsCaptured.Values.ToList(), new List <Point>()
            {
                _touchPadStartPoint
            }) :
                                                        new PointsCapturedEventArgs(new List <List <Point> >(_pointsCaptured.Values), _pointsCaptured.Values.Select(p => p.FirstOrDefault()).ToList());

            // Notify subscribers that capture has ended (draw end)
            OnCaptureEnded();
            State = CaptureState.Ready;

            // Notify PointsCaptured event subscribers that points have been captured.
            //CaptureWindow GetGestureName
            OnBeforePointsCaptured(pointsInformation);

            if (pointsInformation.Cancel)
            {
                return;
            }

            if (Mode == CaptureMode.Training && !(_pointsCaptured.Count == 1 && _pointsCaptured.Values.First().Count == 1))
            {
                _pointPatternCache.Clear();
                _pointPatternCache.Add(new PointPattern(_pointsCaptured.Values));

                if (!NamedPipe.SendMessageAsync(IpcCommands.GotGesture, Constants.ControlPanel, _pointPatternCache.Select(p => p.Points).ToArray(), false).Result)
                {
                    Mode = CaptureMode.Normal;
                }
            }

            // Fire recognized event if we found a gesture match, otherwise throw not recognized event
            if (GestureManager.Instance.GestureName != null)
            {
                List <Point> capturedPoints = SourceDevice == Devices.TouchPad ? new List <Point>()
                {
                    _touchPadStartPoint
                } : pointsInformation.FirstCapturedPoints;
                OnGestureRecognized(new RecognitionEventArgs(GestureManager.Instance.GestureName, pointsInformation.Points, capturedPoints, _pointsCaptured.Keys.ToList()));
            }
            //else
            //    OnGestureNotRecognized(new RecognitionEventArgs(pointsInformation.Points, pointsInformation.FirstCapturedPoints, _pointsCaptured.Keys.ToList()));

            OnAfterPointsCaptured(pointsInformation);

            _pointsCaptured.Clear();
        }
예제 #15
0
 private async Task <bool> SetTrainingState(bool state)
 {
     if (state)
     {
         DrawGestureTextBlock.Visibility = Visibility.Visible;
         StackUpGestureButton.IsEnabled  = ResetButton.IsEnabled = false;
         return(await NamedPipe.SendMessageAsync("StartTeaching", "GestureSignDaemon"));
     }
     else
     {
         DrawGestureTextBlock.Visibility = Visibility.Collapsed;
         ResetButton.IsEnabled           = true;
         return(await NamedPipe.SendMessageAsync("StopTraining", "GestureSignDaemon"));
     }
 }
예제 #16
0
        public void StartPipe(string pipeName, ConnectionMode mode)
        {
            mPipeName = pipeName;
            mMode     = mode;

            Close();
            ConnectionMode = Mode.PipeMode;

            mNamedPipe = new NamedPipe();
            mNamedPipe.ClientConnectedEvent    += new EventHandler(NamedPipe_ClientConnectedEvent);
            mNamedPipe.ClientDisconnectedEvent += new EventHandler(NamedPipe_ClientDisconectedEvent);
            mNamedPipe.PipeReceiveEvent        += new PipeReceiveEventHandler(PipeReceiveEvent);
            mNamedPipe.PipeErrorEvent          += new PipeErrorEventHandler(MediumErrorEvent);

            mNamedPipe.CreatePipe(pipeName, mode);
        }
예제 #17
0
 private async void btnAddGesture_Click(object sender, RoutedEventArgs e)
 {
     if (await UIHelper.GetParentWindow(this).ShowMessageAsync(
             LocalizationProvider.Instance.GetTextValue("Gesture.Messages.AddGestureTitle"),
             LocalizationProvider.Instance.GetTextValue("Gesture.Messages.AddGesture"),
             MessageDialogStyle.AffirmativeAndNegative,
             new MetroDialogSettings()
     {
         AnimateHide = false,
         AnimateShow = false,
         AffirmativeButtonText = LocalizationProvider.Instance.GetTextValue("Common.OK"),
         NegativeButtonText = LocalizationProvider.Instance.GetTextValue("Common.Cancel")
     }) == MessageDialogResult.Affirmative)
     {
         await NamedPipe.SendMessageAsync("StartTeaching", "GestureSignDaemon");
     }
 }
예제 #18
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            try
            {
                Logging.OpenLogFile();
                LoadLanguageData();

                if (AppConfig.UiAccess && Environment.OSVersion.Version.Major == 10)
                {
                    if (TryLaunchStoreVersion())
                    {
                        return;
                    }
                }

                bool createdNew;
                mutex = new Mutex(true, "GestureSignControlPanel", out createdNew);
                if (createdNew)
                {
                    GestureManager.Instance.Load(null);
                    GestureSign.Common.Plugins.PluginManager.Instance.Load(null);
                    ApplicationManager.Instance.Load(null);

                    NamedPipe.Instance.RunNamedPipeServer("GestureSignControlPanel", new MessageProcessor());

                    ApplicationManager.ApplicationSaved += (o, ea) => NamedPipe.SendMessageAsync("LoadApplications", "GestureSignDaemon");
                    GestureManager.GestureSaved         += (o, ea) => NamedPipe.SendMessageAsync("LoadGestures", "GestureSignDaemon");

                    MainWindow mainWindow = new MainWindow();
                    mainWindow.Show();
                }
                else
                {
                    ShowControlPanel();
                    // use Dispatcher to resolve exception 0xc0020001
                    Current.Dispatcher.InvokeAsync(() => Current.Shutdown(), DispatcherPriority.ApplicationIdle);
                }
            }
            catch (Exception exception)
            {
                Logging.LogException(exception);
                MessageBox.Show(exception.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
                Current.Shutdown();
            }
        }
예제 #19
0
 private void SetTrainingState(bool state)
 {
     if (state)
     {
         CurrentGesture = null;
         DrawGestureTextBlock.Visibility = Visibility.Visible;
         ExistingTextBlock.Visibility    = RedrawButton.Visibility = Visibility.Collapsed;
         MessageProcessor.GotNewPattern += MessageProcessor_GotNewPattern;
         NamedPipe.SendMessageAsync("StartTeaching", "GestureSignDaemon");
     }
     else
     {
         DrawGestureTextBlock.Visibility = Visibility.Collapsed;
         RedrawButton.Visibility         = Visibility.Visible;
         MessageProcessor.GotNewPattern -= MessageProcessor_GotNewPattern;
         NamedPipe.SendMessageAsync("StopTraining", "GestureSignDaemon");
     }
 }
예제 #20
0
        public MainWindow()
        {
            InitializeComponent();
            ViewModel   = new MainWindowViewModel(this);
            DataContext = ViewModel;
            Instance    = this;

            NamedPipe <string> beatSaverPipe = new NamedPipe <string>(NamedPipe <string> .NameTypes.BeatSaver);

            beatSaverPipe.OnRequest += new NamedPipe <string> .Request(BeatSaverPipe_OnRequest);

            beatSaverPipe.Start();

            NamedPipe <string> modelSaberPipe = new NamedPipe <string>(NamedPipe <string> .NameTypes.ModelSaber);

            modelSaberPipe.OnRequest += new NamedPipe <string> .Request(ModelSaberPipe_OnRequest);

            modelSaberPipe.Start();
        }
예제 #21
0
        private void CheckDeviceStates()
        {
            NamedPipe.GetMessageAsync(GestureSign.Common.Constants.Daemon + "DeviceState", 2000).ContinueWith(
                t =>
            {
                if (t.Result == null)
                {
                    return;
                }

                Dispatcher.Invoke(() =>
                {
                    Devices deviceState = (Devices)t.Result;
                    Brush brush         = (Brush)TryFindResource("AccentBaseColorBrush");
                    TouchScreenNotFoundText.Foreground = (deviceState & Devices.TouchScreen) != 0 ? Brushes.Transparent : brush;
                    TouchPadNotFoundText.Foreground    = (deviceState & Devices.TouchPad) != 0 ? Brushes.Transparent : brush;
                    PenNotFoundText.Foreground         = (deviceState & Devices.Pen) != 0 ? Brushes.Transparent : brush;
                }, System.Windows.Threading.DispatcherPriority.Loaded);
            });
        }
예제 #22
0
        public bool Setup()
        {
            // setup output named pipe
            DataOutputStream = new NamedPipe();
            string output = ((NamedPipe)DataOutputStream).Url;

            StreamLog.Info(context.Identifier, "VLCManagedEncoder: starting output named pipe {0}", output);
            ((NamedPipe)DataOutputStream).Start(false);

            // prepare sout, needs some trickery for vlc
            string realSout = sout.Replace("#OUT#", @"\" + output);

            // debug
            StreamLog.Debug(context.Identifier, "VLCManagedEncoder: sout {0}", realSout);
            StreamLog.Debug(context.Identifier, "VLCManagedEncoder: arguments {0}", String.Join("|", arguments));

            // start vlc
            transcoder = new VLCTranscoder();
            transcoder.SetArguments(arguments);
            transcoder.SetMediaName(Guid.NewGuid().ToString());
            transcoder.SetSout(realSout);

            // setup input
            if (inputMethod == InputMethod.NamedPipe)
            {
                transcoderInputStream = new NamedPipe();
                StreamLog.Info(context.Identifier, "VLCManagedEncoder: starting input named pipe {0}", transcoderInputStream);
                ((NamedPipe)transcoderInputStream).Start(false);
                inputPath = "stream://" + transcoderInputStream.Url; // use special syntax for VLC to pick up named pipe
            }
            StreamLog.Debug(context.Identifier, "VLCManagedEncoder: input {0}", inputPath);
            transcoder.SetInput(inputPath);

            // start transcoding
            transcoder.StartTranscoding();
            // doesn't work
            //transcoder.Seek(startPos * 1.0 / context.MediaInfo.Duration * 1000);

            context.TranscodingInfo.Supported = true;
            return(true);
        }
예제 #23
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Logging.LoggedExceptionOccurred += (o, ex) => ShowException(ex);
            Logging.OpenLogFile();
            LoadLanguageData();

            bool createdNew;

            mutex = new Mutex(true, Constants.ControlPanel, out createdNew);
            if (createdNew)
            {
                if (AppConfig.UiAccess && VersionHelper.IsWindows10OrGreater())
                {
                    if (TryLaunchStoreVersion())
                    {
                        return;
                    }
                }

                GestureManager.Instance.Load(null);
                GestureSign.Common.Plugins.PluginManager.Instance.Load(null);
                ApplicationManager.Instance.Load(null);

                NamedPipe.Instance.RunNamedPipeServer(Constants.ControlPanel, new MessageProcessor());

                ApplicationManager.ApplicationSaved += (o, ea) => NamedPipe.SendMessageAsync(IpcCommands.LoadApplications, Constants.Daemon);
                GestureManager.GestureSaved         += (o, ea) => NamedPipe.SendMessageAsync(IpcCommands.LoadGestures, Constants.Daemon);
                AppConfig.ConfigChanged             += (o, ea) =>
                {
                    NamedPipe.SendMessageAsync(IpcCommands.LoadConfiguration, Constants.Daemon);
                };
                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
            }
            else
            {
                ShowControlPanel();
                // use Dispatcher to resolve exception 0xc0020001
                Current.Dispatcher.InvokeAsync(() => Current.Shutdown(), DispatcherPriority.ApplicationIdle);
            }
        }
예제 #24
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Logging.OpenLogFile();
            LoadLanguageData();

            bool createdNew;

            mutex = new Mutex(true, "GestureSignControlPanel", out createdNew);
            if (createdNew)
            {
                if (AppConfig.UiAccess && Environment.OSVersion.Version.Major == 10)
                {
                    if (TryLaunchStoreVersion())
                    {
                        return;
                    }
                }

                GestureManager.Instance.Load(null);
                GestureSign.Common.Plugins.PluginManager.Instance.Load(null);
                ApplicationManager.Instance.Load(null);

                NamedPipe.Instance.RunNamedPipeServer("GestureSignControlPanel", new MessageProcessor());

                ApplicationManager.ApplicationSaved += (o, ea) => NamedPipe.SendMessageAsync("LoadApplications", "GestureSignDaemon");
                GestureManager.GestureSaved         += (o, ea) => NamedPipe.SendMessageAsync("LoadGestures", "GestureSignDaemon");
                AppConfig.ConfigChanged             += (o, ea) =>
                {
                    NamedPipe.SendMessageAsync("LoadConfiguration", "TouchInputProviderMessage");
                    NamedPipe.SendMessageAsync("LoadConfiguration", "GestureSignDaemon");
                };
                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
            }
            else
            {
                ShowControlPanel();
                // use Dispatcher to resolve exception 0xc0020001
                Current.Dispatcher.InvokeAsync(() => Current.Shutdown(), DispatcherPriority.ApplicationIdle);
            }
        }
예제 #25
0
        private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            BindExistingApplications();
            BindPlugins();

            if (_currentAction != null)
            {
                //cmbExistingApplication.SelectedItem = ApplicationManager.Instance.CurrentApplication;
                foreach (object comboItem in cmbPlugins.Items)
                {
                    IPluginInfo pluginInfo = (IPluginInfo)comboItem;

                    if (pluginInfo.Class == _currentAction.PluginClass && pluginInfo.Filename == _currentAction.PluginFilename)
                    {
                        cmbPlugins.SelectedIndex = cmbPlugins.Items.IndexOf(comboItem);
                        return;
                    }
                }
            }

            NamedPipe.SendMessageAsync("DisableTouchCapture", "GestureSignDaemon");
        }
예제 #26
0
        private static void SaveFile(object state)
        {
            try
            {
                FileManager.WaitFile(Path);
                // Save the configuration file.
                _config.AppSettings.SectionInformation.ForceSave = true;
                _config.Save(ConfigurationSaveMode.Modified);
            }
            catch (ConfigurationErrorsException)
            {
                Reload();
            }
            catch (Exception e)
            {
                Logging.LogException(e);
            }
            // Force a reload of the changed section.
            ConfigurationManager.RefreshSection("appSettings");

            NamedPipe.SendMessageAsync("LoadConfiguration", "GestureSignDaemon");
        }
예제 #27
0
        private async void Application_Startup(object sender, StartupEventArgs e)
        {
            try
            {
                Logging.OpenLogFile();
                LoadLanguageData();

                string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "GestureSignDaemon.exe");
                if (!File.Exists(path))
                {
                    MessageBox.Show(LocalizationProvider.Instance.GetTextValue("Messages.CannotFindDaemonMessage"),
                                    LocalizationProvider.Instance.GetTextValue("Messages.Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                    Current.Shutdown();
                    return;
                }

                if (CheckIfApplicationRunAsAdmin())
                {
                    var result = MessageBox.Show(LocalizationProvider.Instance.GetTextValue("Messages.CompatWarning"),
                                                 LocalizationProvider.Instance.GetTextValue("Messages.CompatWarningTitle"), MessageBoxButton.YesNo,
                                                 MessageBoxImage.Warning);

                    if (result == MessageBoxResult.No)
                    {
                        Current.Shutdown();
                        return;
                    }
                }

                bool createdNewDaemon;
                using (new Mutex(false, "GestureSignDaemon", out createdNewDaemon))
                {
                }
                if (createdNewDaemon)
                {
                    using (Process daemon = new Process())
                    {
                        daemon.StartInfo.FileName = path;

                        //daemon.StartInfo.UseShellExecute = false;
                        if (IsAdministrator())
                        {
                            daemon.StartInfo.Verb = "runas";
                        }
                        daemon.StartInfo.CreateNoWindow = false;
                        daemon.Start();
                    }
                    Current.Shutdown();
                }
                else
                {
                    bool createdNew;
                    mutex = new Mutex(true, "GestureSignControlPanel", out createdNew);
                    if (createdNew)
                    {
                        var systemAccent = UIHelper.GetSystemAccent();
                        if (systemAccent != null)
                        {
                            var accent = ThemeManager.GetAccent(systemAccent);
                            ThemeManager.ChangeAppStyle(Current, accent, ThemeManager.GetAppTheme("BaseLight"));
                        }

                        if (e.Args.Length != 0 && e.Args[0].Equals("/L"))
                        {
                            Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
                            Timer.Change(300000, Timeout.Infinite);
                        }
                        else
                        {
                            MainWindow mainWindow = new MainWindow();
                            mainWindow.Show();
                        }

                        GestureManager.Instance.Load(null);
                        PluginManager.Instance.Load(null);
                        ApplicationManager.Instance.Load(null);

                        NamedPipe.Instance.RunNamedPipeServer("GestureSignControlPanel", new MessageProcessor());
                    }
                    else
                    {
                        await NamedPipe.SendMessageAsync("MainWindow", "GestureSignControlPanel");

                        Current.Shutdown();
                    }
                }
            }
            catch (Exception exception)
            {
                Logging.LogException(exception);
                MessageBox.Show(exception.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Current.Shutdown();
            }
        }
예제 #28
0
 private void ShowTrayIconSwitch_Unchecked(object sender, RoutedEventArgs e)
 {
     NamedPipe.SendMessageAsync("HideTrayIcon", "GestureSignDaemon");
     AppConfig.ShowTrayIcon = false;
 }
예제 #29
0
 Task <Stream> IStreamStratergy.Provide(StreamType type, string streamName, CancellationToken token)
 {
     return(NamedPipe.Provide(type, streamName, token));
 }
예제 #30
0
        private void SetupTrayIconAndTrayMenu()
        {
            _trayIcon = new NotifyIcon();
            _trayMenu = new ContextMenu();
            _disableGesturesMenuItem = new MenuItem();
            _controlPanelMenuItem    = new MenuItem();
            _exitGestureSignMenuItem = new MenuItem();

            // Tray Icon
            _trayIcon.ContextMenu  = _trayMenu;
            _trayIcon.Text         = "GestureSign";
            _trayIcon.DoubleClick += (o, e) => { TrayIcon_Click(o, (MouseEventArgs)e); };
            _trayIcon.Click       += (o, e) => { TrayIcon_Click(o, (MouseEventArgs)e); };
            _trayIcon.Icon         = Resources.normal_daemon;

            // Tray Menu
            _trayMenu.MenuItems.AddRange(new MenuItem[] { _disableGesturesMenuItem, new MenuItem("-"), _controlPanelMenuItem, new MenuItem("-"), _exitGestureSignMenuItem });
            _trayMenu.Name = "TrayMenu";
            //TrayMenu.Size = new Size(194, 82);
            //TrayMenu.Opened += (o, e) => { Input.TouchCapture.Instance.DisableTouchCapture(); };
            //TrayMenu.Closed += (o, e) => { Input.TouchCapture.Instance.EnableTouchCapture(); };

            // Disable Gestures Menu Item
            _disableGesturesMenuItem.Checked = false;
            //miDisableGestures.CheckOnClick = true;
            _disableGesturesMenuItem.Name = "DisableGesturesMenuItem";
            //miDisableGestures.Size = new Size(193, 22);
            _disableGesturesMenuItem.Text   = LocalizationProvider.Instance.GetTextValue("TrayMenu.Disable");
            _disableGesturesMenuItem.Click += (o, e) => { ToggleDisableGestures(); };


            // Control Panel Menu Item
            _controlPanelMenuItem.Name = "ControlPanel";
            //_controlPanelMenuItem.Size = new Size(193, 22);
            _controlPanelMenuItem.Text   = LocalizationProvider.Instance.GetTextValue("TrayMenu.ControlPanel");
            _controlPanelMenuItem.Click += (o, e) =>
            {
                string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "GestureSign.exe");
                if (File.Exists(path))
                {
                    using (Process daemon = new Process())
                    {
                        try
                        {
                            daemon.StartInfo.FileName = path;

                            //daemon.StartInfo.UseShellExecute = false;
                            daemon.Start();
                        }
                        catch (Exception exception)
                        {
                            Logging.LogException(exception);
                            MessageBox.Show(exception.ToString(),
                                            LocalizationProvider.Instance.GetTextValue("Messages.Error"), MessageBoxButtons.OK,
                                            MessageBoxIcon.Warning);
                        }
                    }
                }
            };

            _exitGestureSignMenuItem.Name = "ExitGestureSign";
            //miExitGestureSign.Size = new Size(193, 22);
            _exitGestureSignMenuItem.Text   = LocalizationProvider.Instance.GetTextValue("TrayMenu.Exit");
            _exitGestureSignMenuItem.Click += async(o, e) =>
            {
                await NamedPipe.SendMessageAsync("Exit", "GestureSignControlPanel", false);

                // try to fix exception 0xc0020001
                Application.DoEvents();
                Application.Exit();
            };
        }