Esempio n. 1
0
 public IRegisteredShortcut RegisterShortcut(IShortcut iShortcut, IOperation operation)
 {
     if (OnRegisterShortcut == null)
     {
         if (iShortcut is ShortcutMock shortcut)
         {
             if (!RegisteredShortcuts.ContainsKey(shortcut.Key.Name))
             {
                 RegisteredShortcuts[shortcut.Key.Name] = new Dictionary <KeyModifier, RegisteredShortcutMock>();
             }
             if (!RegisteredShortcuts[shortcut.Key.Name].ContainsKey(shortcut.KeyModifier))
             {
                 var registeredShortcut = new RegisteredShortcutMock(shortcut, operation);
                 RegisteredShortcuts[shortcut.Key.Name][shortcut.KeyModifier] = registeredShortcut;
                 return(registeredShortcut);
             }
             return(null);
         }
         throw new NotImplementedException();
     }
     else
     {
         return(OnRegisterShortcut(iShortcut, operation));
     }
 }
        /// <summary>
        /// Creates a new instance of the <see cref="GuidanceShortcut"/> class.
        /// </summary>
        public GuidanceShortcut(IShortcut shortcut)
        {
            Guard.NotNull(() => shortcut, shortcut);

            this.shortcut = shortcut;
            this.Parameters = shortcut.Parameters ?? new Dictionary<string, string>();
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a new instance of the <see cref="GuidanceShortcut"/> class.
        /// </summary>
        public GuidanceShortcut(IShortcut shortcut)
        {
            Guard.NotNull(() => shortcut, shortcut);

            this.shortcut   = shortcut;
            this.Parameters = shortcut.Parameters ?? new Dictionary <string, string>();
        }
Esempio n. 4
0
 public RelayUICommand(string text, IImage icon, IShortcut keyGesture,
                       Action <T> execute, Func <T, bool> canExecute)
     : base(execute, canExecute)
 {
     this.text       = text;
     this.icon       = icon;
     this.keyGesture = keyGesture;
 }
        public void DeleteShortcut(string path, IShortcut shortcut)
        {
            var fullName = System.IO.Path.Combine(path, System.IO.Path.GetFileName(shortcut.FullName));

            if (System.IO.File.Exists(fullName))
            {
                System.IO.File.Delete(fullName);
            }
        }
 /// <summary>
 ///     Construtor.
 /// </summary>
 /// <param name="messageBus">IMediator</param>
 /// <param name="shortcut">Configurações de teclas de atalho.</param>
 /// <param name="lockScreen">Bloqueador de telas.</param>
 public ApplicationHandler(
     IMediator messageBus,
     IShortcut shortcut,
     ILockScreen lockScreen)
 {
     _messageBus = messageBus;
     _shortcut   = shortcut;
     _lockScreen = lockScreen;
 }
 public ShortcutForDisplay(IShortcut shortcut)
 {
     IconLocation     = shortcut.IconLocation;
     TargetPath       = shortcut.TargetPath;
     Arguments        = shortcut.Arguments;
     WorkingDirectory = shortcut.WorkingDirectory;
     WindowStyle      = shortcut.WindowStyle;
     Description      = shortcut.Description;
     FullName         = shortcut.FullName;
 }
Esempio n. 8
0
        /// <summary>
        /// Creates a new shortcut from given shortcut
        /// </summary>
        /// <param name="shortcut">A shortcut to use</param>
        public static Shortcut CreateShortcut(IShortcut shortcut)
        {
            var newShortcut = new Shortcut
                {
                    Type = shortcut.Type,
                    Description = shortcut.Description,
                };
            newShortcut.Parameters.AddRange(shortcut.Parameters);

            return newShortcut;
        }
Esempio n. 9
0
        /// <summary>
        /// Creates a new shortcut from given shortcut
        /// </summary>
        /// <param name="shortcut">A shortcut to use</param>
        public static Shortcut CreateShortcut(IShortcut shortcut)
        {
            var newShortcut = new Shortcut
            {
                Type        = shortcut.Type,
                Description = shortcut.Description,
            };

            newShortcut.Parameters.AddRange(shortcut.Parameters);

            return(newShortcut);
        }
Esempio n. 10
0
        protected override void OnStart()
        {
            _Shortcut = new MultiKeyboardShortcut(((HS2VRSettings)VR.Settings).Capture.Shortcut, delegate
            {
                VRLog.Info($"Initiating VR Screenshot Capture");
                CaptureStart();
            });

            AccessTools.Field(typeof(SteamVR_SphericalProjection), "material").SetValue(null, new Material(UnityHelper.GetShader("Custom/SteamVR_SphericalProjection")));
            VRLog.Info($"Set Material {AccessTools.Field(typeof(SteamVR_SphericalProjection), "material").GetValue(null)}");

            base.OnStart();
        }
        public bool Equals(IShortcut other)
        {
            if (IconLocation != other.IconLocation ||
                TargetPath != other.TargetPath ||
                Arguments != other.Arguments ||
                WorkingDirectory != other.WorkingDirectory ||
                WindowStyle != other.WindowStyle ||
                Description != other.Description ||
                FullName != other.FullName)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 12
0
        private static void SerializeShortcutToStream(IShortcut shortcut, Stream stream)
        {
            var serializer = new XmlSerializer(typeof(Shortcut));

            using (var writer = XmlTextWriter.Create(stream, new XmlWriterSettings
            {
                OmitXmlDeclaration = true,
                Encoding = Encoding.UTF8,
                Indent = true,
            }))
            {
                // Serialize the shortcut (no XSD XSI namespaces)
                var ns = new XmlSerializerNamespaces();
                ns.Add(string.Empty, string.Empty);
                serializer.Serialize(writer, shortcut, ns);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Resolves the shortcut to an instance of the shortcut.
        /// </summary>
        /// <param name="shortcut">The shortcut</param>
        public IShortcut ResolveShortcut(IShortcut shortcut)
        {
            if (!this.Providers.Any())
            {
                return(null);
            }

            try
            {
                // it is not ok to cast provider to IShortcutProvider<T> this would only be valid of IShortcutProvider<T> is covariant.
                dynamic provider = GetProvidersAssignableTo(shortcut.Type).Single();
                return((IShortcut)provider.GetType().InvokeMember(@"ResolveShortcut",
                                                                  BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod, null, provider, new object[] { shortcut }));
            }
            catch (Exception ex)
            {
                throw new NotSupportedException(
                          string.Format(Resources.ShortcutLaunchService_ErrorFailedResolveShortcutUntyped, shortcut.Type),
                          ex);
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Serialize the shortcut
        /// </summary>
        public static string SerializeShortcut(IShortcut shortcut)
        {
            try
            {
                using (var stream = new MemoryStream())
                {
                    SerializeShortcutToStream(shortcut, stream);

                    // Read the serialized data
                    using (var reader = new StreamReader(stream))
                    {
                        stream.Position = 0;
                        return(reader.ReadToEnd());
                    }
                }
            }
            catch (Exception)
            {
                throw new ShortcutFileAccessException();
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Writes the shortcut to the specified file.
        /// </summary>
        /// <param name="shortcut">The shortcut to write to the file</param>
        public void WriteShortcut(IShortcut shortcut)
        {
            Guard.NotNull(() => shortcut, shortcut);

            if (!Directory.Exists(Path.GetDirectoryName(this.FilePath)))
            {
                throw new DirectoryNotFoundException();
            }

            try
            {
                using (var stream = new FileStream(this.FilePath, FileMode.OpenOrCreate))
                {
                    SerializeShortcutToStream(shortcut, stream);
                }
            }
            catch (Exception)
            {
                throw new ShortcutFileAccessException();
            }
        }
        public void SaveShortcut(string path, IShortcut shortcut)
        {
            var fullName = System.IO.Path.Combine(path, System.IO.Path.GetFileName(shortcut.FullName));

            if (System.IO.File.Exists(fullName))
            {
                System.IO.File.Delete(fullName);
            }
            shortcut.FullName = fullName;

            var wshShortcut = ConvertIShortcutToIWshShortcut(shortcut);

            try
            {
                wshShortcut.Save();
            }
            finally
            {
                System.Runtime.InteropServices.Marshal.FinalReleaseComObject(wshShortcut);
            }
        }
        /// <summary>
        /// Writes the shortcut to the specified file.
        /// </summary>
        /// <param name="shortcut">The shortcut to write to the file</param>
        public void WriteShortcut(IShortcut shortcut)
        {
            Guard.NotNull(() => shortcut, shortcut);

            if (!Directory.Exists(Path.GetDirectoryName(this.FilePath)))
            {
                throw new DirectoryNotFoundException();
            }

            try
            {
                using (var stream = new FileStream(this.FilePath, FileMode.OpenOrCreate))
                {
                    SerializeShortcutToStream(shortcut, stream);
                }
            }
            catch (Exception)
            {
                throw new ShortcutFileAccessException();
            }
        }
Esempio n. 18
0
 public IRegisteredShortcut RegisterShortcut(IShortcut iShortcut, IOperation operation)
 {
     if (iShortcut is Shortcut <E> shortcut)
     {
         try
         {
             int id = NextIdToRegister;
             NextIdToRegister += 1;
             var result = RegisterHotKey(shortcut, id);
             this.LogLine("RegisterHotKey/{3}({0}, {1}, {2}) => {4}", id, operation.Name, shortcut.Name, GetType().Name, result.ToRepr());
             if (result)
             {
                 var registeredShortcut = new RegisteredShortcut <E>(shortcut, operation, id);
                 RegisteredShortcuts[id] = registeredShortcut;
                 return(registeredShortcut);
             }
         }
         catch
         {
         }
     }
     return(null);
 }
Esempio n. 19
0
        protected override void OnStart()
        {
            // Get shaders
            fadeMaterial                = UnityHelper.LoadFromAssetBundle <Material>(Resource.capture, "Fade material");
            convertPanoramaShader       = UnityHelper.LoadFromAssetBundle <ComputeShader>(Resource.capture, "ConvertPanoramaShader");
            convertPanoramaStereoShader = UnityHelper.LoadFromAssetBundle <ComputeShader>(Resource.capture, "ConvertPanoramaStereoShader");
            textureToBufferShader       = UnityHelper.LoadFromAssetBundle <ComputeShader>(Resource.capture, "TextureToBufferShader");

            captureStereoscopic    = VR.Settings.Capture.Stereoscopic;
            interpupillaryDistance = SteamVR.instance.GetFloatProperty(ETrackedDeviceProperty.Prop_UserIpdMeters_Float) * VR.Settings.IPDScale;
            captureKey             = KeyCode.None;

            _Shortcut = new MultiKeyboardShortcut(VR.Settings.Capture.Shortcut, delegate
            {
                if (!Capturing)
                {
                    string filenameBase = String.Format("{0}_{1:yyyy-MM-dd_HH-mm-ss-fff}", Application.productName, DateTime.Now);
                    VRLog.Info("Panorama capture key pressed, capturing " + filenameBase);
                    CaptureScreenshotAsync(filenameBase);;
                }
            });

            base.OnStart();
        }
        private static void SerializeShortcutToStream(IShortcut shortcut, Stream stream)
        {
            var serializer = new XmlSerializer(typeof(Shortcut));

            using (var writer = XmlTextWriter.Create(stream, new XmlWriterSettings
            {
                OmitXmlDeclaration = true,
                Encoding = Encoding.UTF8,
                Indent = true,
            }))
            {
                // Serialize the shortcut (no XSD XSI namespaces)
                var ns = new XmlSerializerNamespaces();
                ns.Add(string.Empty, string.Empty);
                serializer.Serialize(writer, shortcut, ns);
            }
        }
        /// <summary>
        /// 自作IShortcutのインスタンスからWSHのIWshShortcutのインスタンスを生成し返します。
        /// </summary>
        /// <param name="shortcut">コピー対象の自作ショートカットオブジェクト</param>
        /// <returns>WSH版ショートカットオブジェクト</returns>
        private static IWshRuntimeLibrary.IWshShortcut ConvertIShortcutToIWshShortcut(IShortcut shortcut)
        {
            var shell = new IWshRuntimeLibrary.WshShell();

            var ret = shell.CreateShortcut(shortcut.FullName) as IWshRuntimeLibrary.IWshShortcut;

            ret.IconLocation     = shortcut.IconLocation;
            ret.TargetPath       = shortcut.TargetPath;
            ret.Arguments        = shortcut.Arguments;
            ret.WorkingDirectory = shortcut.WorkingDirectory;
            ret.WindowStyle      = (int)shortcut.WindowStyle;
            ret.Description      = shortcut.Description;

            return(ret);
        }
Esempio n. 22
0
 /// <summary>
 /// Adds the shortcut.
 /// </summary>
 /// <param name="shortcut">The shortcut.</param>
 public void AddShortcut(IShortcut shortcut)
 {
     _shortcuts.Add(shortcut);
 }
Esempio n. 23
0
 /// <summary>
 /// Removes the shortcut.
 /// </summary>
 /// <param name="shortcut">The shortcut.</param>
 public void RemoveShortcut(IShortcut shortcut)
 {
     _shortcuts.Remove(shortcut);
 }
 /// <summary>
 /// Resolves the shortcut to an instance of the pattern shortcut.
 /// </summary>
 /// <param name="shortcut">The shortcut to resolve</param>
 /// <returns></returns>
 public GuidanceShortcut ResolveShortcut(IShortcut shortcut)
 {
     return(new GuidanceShortcut(shortcut));
 }
Esempio n. 25
0
 public RelayUICommand(string text, IImage icon, IShortcut keyGesture,
                       Action <T> execute)
     : this(text, icon, keyGesture, execute, null)
 {
 }
Esempio n. 26
0
 /// <summary>Gets or creates a new command with the specified parameters.</summary>
 ///
 /// <typeparam name="T">The parameter type of the command.</typeparam>
 /// <param name="text">The display text for the command.</param>
 /// <param name="icon">The display icon for the command.</param>
 /// <param name="keyGesture">The keybind for the command.</param>
 /// <param name="execute">The execute method for the command.</param>
 /// <param name="canExecute">The optional canExecute method for the command.</param>
 /// <param name="commandName">The name of the command to get or set.</param>
 /// <returns>The existing or created command.</returns>
 protected RelayUICommand <T> GetCommand <T>(string text, IImage icon, IShortcut keyGesture,
                                             Action <T> execute, Func <T, bool> canExecute = null, [CallerMemberName] string commandName = null)
 {
     return(GetCommand(() => new RelayUICommand <T>(text, icon, keyGesture, execute, canExecute), commandName));
 }
Esempio n. 27
0
 /// <summary>Gets or creates a new command with the specified parameters.</summary>
 ///
 /// <param name="text">The display text for the command.</param>
 /// <param name="icon">The display icon for the command.</param>
 /// <param name="keyGesture">The keybind for the command.</param>
 /// <param name="execute">The execute method for the command.</param>
 /// <param name="canExecute">The optional canExecute method for the command.</param>
 /// <param name="commandName">The name of the command to get or set.</param>
 /// <returns>The existing or created command.</returns>
 protected RelayUICommand GetCommand(string text, IShortcut keyGesture, Action execute,
                                     Func <bool> canExecute = null, [CallerMemberName] string commandName = null)
 {
     return(GetCommand(text, null, keyGesture, execute, canExecute, commandName));
 }
Esempio n. 28
0
 /// <summary>
 /// Removes the shortcut.
 /// </summary>
 /// <param name="shortcut">The shortcut.</param>
 public void RemoveShortcut(IShortcut shortcut)
 {
     shortcuts.Remove(shortcut);
 }
Esempio n. 29
0
 public void DeleteStartupShortcut(IShortcut shortcut)
 {
     _shortcutService.DeleteShortcut(StartupPath, shortcut);
 }
        /// <summary>
        /// Serialize the shortcut
        /// </summary>
        public static string SerializeShortcut(IShortcut shortcut)
        {
            try
            {
                using (var stream = new MemoryStream())
                {
                    SerializeShortcutToStream(shortcut, stream);

                    // Read the serialized data
                    using (var reader = new StreamReader(stream))
                    {
                        stream.Position = 0;
                        return reader.ReadToEnd();
                    }
                }
            }
            catch (Exception)
            {
                throw new ShortcutFileAccessException();
            }
        }
 public MainMenuViewModel(IShortcut[] menuItems)
 {
     this.menuItems = new BindableCollection<IShortcut>(menuItems);
 }
Esempio n. 32
0
 /// <summary>
 /// Adds the shortcut.
 /// </summary>
 /// <param name="shortcut">The shortcut.</param>
 public void AddShortcut(IShortcut shortcut)
 {
     shortcuts.Add(shortcut);
 }