private void ShortcutProperties(bool isNew = false)
        {
            _shorcutProperties = new FormShortcutProperties();
            DesktopComposer.Implementation.Shortcut shortcut;
            if (isNew)
            {
                shortcut = new DesktopComposer.Implementation.Shortcut
                {
                    MenuPath = NodeRelativePath(tvStartMenu.SelectedNode.FullPath, true)
                };
            }
            else
            {
                shortcut = GetShorcutFromNode();
            }

            if (_shorcutProperties.ShowDialog(shortcut) == DialogResult.OK)
            {
                if (isNew)
                {
                    _Shortcuts.Add(shortcut);
                    AddNode(shortcut);
                }
                else
                {
                    tvStartMenu.SelectedNode.Text = shortcut.DisplayName;
                    imlIcons.Images[imlIcons.Images.IndexOfKey(tvStartMenu.SelectedNode.ImageKey)] = shortcut.IconCacheSmall.ToBitmap();
                }
                InvokeDataChanged();
            }
        }
Ejemplo n.º 2
0
        private void ShortcutProperties(bool isNew = false)
        {
            _shorcutProperties = new FormShortcutProperties();
            DesktopComposer.Implementation.Shortcut shortcut;
            if (isNew)
            {
                shortcut = new DesktopComposer.Implementation.Shortcut
                {
                    MenuPath = NodeRelativePath(tvStartMenu.SelectedNode.FullPath, true)
                };
            }
            else
            {
                shortcut = GetShorcutFromNode();
            }

            if (_shorcutProperties.ShowDialog(shortcut) == DialogResult.OK)
            {
                if (isNew)
                {
                    _Shortcuts.Add(shortcut);
                    AddNode(shortcut);
                }
                else
                {
                    //Update Node
                }
                InvokeDataChanged();
            }
        }
Ejemplo n.º 3
0
        private void AddItem()
        {
            var item = new ShortcutViewModel();

            Shortcuts.Add(item);
            SelectedItem = item;
        }
Ejemplo n.º 4
0
        private void OnLogoutCommand(object obj)
        {
            DialogResult _result = MessageBox.Show("로그아웃 하시겠습니까?", "로그아웃", MessageBoxButtons.OKCancel);

            if (_result != DialogResult.OK)
            {
                return;
            }
            try
            {
                ((RemoteRepository)App.Repo).UpdateAuth(new Auth());
            }
            catch
            {
            }
            finally
            {
                App.Repo = new LocalRepository();
                App.Repo.Load();
                _repo = App.Repo;
                Shortcuts.Clear();
                foreach (var item in App.Repo.ShortcutItems)
                {
                    Shortcuts.Add(item);
                }
                CurrentAuth.UserName = "******";
                App.EA.GetEvent <ItemChanged>().Publish(new List <ShortcutModel>(App.Repo.ShortcutItems));
            }
        }
Ejemplo n.º 5
0
        private void OnLoginCommand(object obj)
        {
            if (_loginWindow != null)
            {
                return;
            }

            _loginWindow = new LoginWindow(_repo.Auth);
            _loginWindow.ShowDialog();

            if (_loginWindow.DialogResult == true)
            {
                var remoteRepo = new RemoteRepository();
                _repo = remoteRepo;
                remoteRepo.UpdateAuth(_loginWindow.Auth);
                _repo.Load();
                App.Repo = _repo;

                CurrentAuth.UserName = _repo.Auth.UserName;

                Shortcuts.Clear();
                foreach (var item in _repo.ShortcutItems)
                {
                    Shortcuts.Add(item);
                }

                App.EA.GetEvent <ItemChanged>().Publish(new List <ShortcutModel>(App.Repo.ShortcutItems));
            }

            _loginWindow = null;
        }
Ejemplo n.º 6
0
 private void LoadShortcuts()
 {
     Shortcuts.Clear();
     foreach (var item in ShortcutServices.LoadExistingShortcuts())
     {
         Shortcuts.Add(new ShortcutViewModel(item));
     }
 }
Ejemplo n.º 7
0
        public bool AddFlag(String name, String shortcut)
        {
            bool result = false;

            if (Flags.Contains(name) == false)
            {
                Flags.Add(name);
                if (String.IsNullOrEmpty(shortcut) == false)
                {
                    Shortcuts.Add(shortcut, name);
                }

                result = true;
            }

            return(result);
        }
Ejemplo n.º 8
0
        public void Add(CharacterShortcut scut)
        {
            if (!CanAdd())
            {
                return;
            }
            var shortcut = GetShortcut(scut.SlotId);

            if (shortcut != null)
            {
                RemoveShortcut(shortcut.SlotId);
            }

            Character.Record.Shortcuts.Add(scut);
            Shortcuts.Add(scut);
            RefreshShortcut(scut);
        }
Ejemplo n.º 9
0
 public Binding(string name, string displayName, string shortcut)
 {
     FullName    = name;
     DisplayName = displayName;
     Shortcuts.Add(shortcut);
 }
Ejemplo n.º 10
0
        public void Load(string directoryPath = null, bool clear = true)
        {
            if (clear)
            {
                Shortcuts.Clear();
            }

            directoryPath = directoryPath ?? $"{Constants.RootPath}";

            if (!Directory.Exists(directoryPath))
            {
                eventBus.Publish(new LogEntryPublished(Constants.ApplicationName, $"Could not locate directory\r\n{Environment.StackTrace}", EventLogEntryType.Information));

                if (directoryPath == Constants.RootPath)
                {
                    Directory.CreateDirectory(Constants.RootPath);
                }

                return;
            }

            //Create default file if it doesn't exist
            var files = Directory.GetFiles(directoryPath).Where(x => x.EndsWith(Constants.ShortcutFileExtension)).ToList();

            if (!files.Any())
            {
                eventBus.Publish(new LogEntryPublished(Constants.ApplicationName, $"No files found in directory\r\n{Environment.StackTrace}", EventLogEntryType.Error));
                var defaultShortcutFilePath = directoryPath + "\\MyShortcuts.hscut";

                var fileStream   = File.Create(defaultShortcutFilePath);
                var streamWriter = new StreamWriter(fileStream);
                streamWriter.Write("//To add a shortcut to a file or whatever\r\n" +
                                   "MySearchSite;\"https://duckduckgo.com/" + Environment.NewLine +
                                   $"{Constants.SearchLocation};\\\\sys.dom\\dfs\\v\\users\\DWAP\\HeibrochLaunch\\");

                streamWriter.Flush();
                streamWriter.Dispose();

                files.Add(defaultShortcutFilePath);
            }

            foreach (var file in files)
            {
                //Add shortcuts in case of modification needed
                var fileInfo = new FileInfo(file);
                Shortcuts.Add(fileInfo.Name, new LaunchShortcut(fileInfo.Name, file));

                var lines = File.ReadAllLines(file);
                foreach (var line in lines)
                {
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        continue;
                    }
                    if (line.StartsWith("//"))
                    {
                        continue;
                    }
                    var values = line.Split(';');

                    if (values[0] == Constants.SearchLocation)
                    {
                        Load(values[1], false);
                        continue;
                    }

                    var plugin = pluginLoader.Plugins.Where(x => !string.IsNullOrWhiteSpace(x.ShortcutFilter)).FirstOrDefault(x => values[1].ToLower().StartsWith(x.ShortcutFilter.ToLower()));

                    //Update or add
                    Shortcuts[values[0]] = plugin?.CreateShortcut(values[0], values[1]) ?? new LaunchShortcut(values[0], values[1]);
                }
            }
        }
Ejemplo n.º 11
0
 public void Add(ILaunchShortcut launchShortcut) => Shortcuts.Add(launchShortcut.Title, launchShortcut);
        public static bool RegisterDefaultShortcut(string tabName, string panelName, string commandId, string commandName, string commandShortcuts)
        {
            commandId = $"CustomCtrl_%CustomCtrl_%{tabName}%{panelName}%{commandId}";

            string keyboardShortcutsPath = Path.Combine(Revit.CurrentUsersDataFolderPath, "KeyboardShortcuts.xml");

            if (!File.Exists(keyboardShortcutsPath))
            {
                keyboardShortcutsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Autodesk", $"RVT {Revit.ApplicationUI.ControlledApplication.VersionNumber}", "UserDataCache", "KeyboardShortcuts.xml");
            }

            if (!LoadFrom(keyboardShortcutsPath, out var shortcuts))
            {
                LoadFromResources($"Resources.RVT{Revit.ApplicationUI.ControlledApplication.VersionNumber}.KeyboardShortcuts.xml", out shortcuts);
            }

#if DEBUG
            // Those lines generate the KeyboardShortcuts.xml template file when new Revit version is supported
            string keyboardShortcutsTemplatePath = Path.Combine(Addin.SourceCodePath, "Resources", $"RVT{Revit.ApplicationUI.ControlledApplication.VersionNumber}", "KeyboardShortcuts.xml");
            var    info = new FileInfo(keyboardShortcutsTemplatePath);
            if (info.Length == 0)
            {
                var shortcutsSummary = new Shortcuts();
                foreach (var shortcutItem in shortcuts.OrderBy(x => x.CommandId))
                {
                    if (!string.IsNullOrEmpty(shortcutItem.Shortcuts))
                    {
                        var shortcutDefinition = new ShortcutItem
                        {
                            CommandId = shortcutItem.CommandId,
                            Shortcuts = shortcutItem.Shortcuts
                        };
                        shortcutsSummary.Add(shortcutDefinition);
                    }
                }

                SaveAs(shortcutsSummary, keyboardShortcutsTemplatePath);
            }
#endif

            bool shortcutUpdated = false;
            try
            {
                var shortcutItem = shortcuts.Where(x => x.CommandId == commandId).First();
                if (shortcutItem.Shortcuts is null)
                {
                    shortcutItem.Shortcuts = commandShortcuts;
                    shortcutUpdated        = true;
                }
            }
            catch (InvalidOperationException)
            {
                var shortcutItem = new ShortcutItem()
                {
                    CommandName = commandName,
                    CommandId   = commandId,
                    Shortcuts   = commandShortcuts,
                    Paths       = $"{tabName}>{panelName}"
                };
                shortcuts.Add(shortcutItem);
                shortcutUpdated = true;
            }

            if (shortcutUpdated)
            {
                SaveAs(shortcuts, Path.Combine(Revit.CurrentUsersDataFolderPath, "KeyboardShortcuts.xml"));
            }

            return(shortcutUpdated);
        }
Ejemplo n.º 13
0
 private void OnAddShortCut(object obj)
 {
     Shortcuts.Add(new ShortcutModel());
     IsModified = true;
 }