public virtual async void OpenFileLocation(RoutedEventArgs e)
        {
            ShortcutItem item = SlimContentPage.SelectedItem as ShortcutItem;

            if (string.IsNullOrWhiteSpace(item?.TargetPath))
            {
                return;
            }

            // Check if destination path exists
            string folderPath = System.IO.Path.GetDirectoryName(item.TargetPath);
            FilesystemResult <StorageFolderWithPath> destFolder = await associatedInstance.FilesystemViewModel.GetFolderWithPathFromPathAsync(folderPath);

            if (destFolder)
            {
                associatedInstance.NavigateWithArguments(associatedInstance.InstanceViewModel.FolderSettings.GetLayoutType(folderPath), new NavigationArguments()
                {
                    NavPathParam          = folderPath,
                    AssociatedTabInstance = associatedInstance
                });
            }
            else if (destFolder == FileSystemStatusCode.NotFound)
            {
                await DialogDisplayHelper.ShowDialogAsync("FileNotFoundDialog/Title".GetLocalized(), "FileNotFoundDialog/Text".GetLocalized());
            }
            else
            {
                await DialogDisplayHelper.ShowDialogAsync("InvalidItemDialogTitle".GetLocalized(),
                                                          string.Format("InvalidItemDialogContent".GetLocalized(), Environment.NewLine, destFolder.ErrorCode.ToString()));
            }
        }
Exemplo n.º 2
0
        private void GenerateShortcutDialogue()
        {
            Boolean isAlwaysAvailable           = true;
            double  inputTimeoutInterval        = double.MaxValue; // No reason to have a timeout here, since the dialogue is _activated_ upon receiving matching input.
            int     inputMaximumRepetitionCount = int.MaxValue;    // No reason to have a repetition count here, for the reason just mentioned.

            Dialogue shortcutDialogue = new Dialogue("ShortcutDialogue", isAlwaysAvailable);

            FriendlyInputItem inputItemShortcutClarify = new FriendlyInputItem("shortcutInput", new List <string> {
                AgentConstants.QUERY_TAG_1, AgentConstants.QUERY_TAG_2
            }, inputTimeoutInterval, inputMaximumRepetitionCount);

            InputAction actionItemTravelClarify = new InputAction(shortcutDialogue.Context, "shortcutProcessing");

            actionItemTravelClarify.PatternList.Add(new Pattern("Set " + AgentConstants.QUERY_TAG_1 + " [as to] " + AgentConstants.QUERY_TAG_2));

            inputItemShortcutClarify.InputAction = actionItemTravelClarify;
            shortcutDialogue.DialogueItemList.Add(inputItemShortcutClarify);


            ShortcutItem shortcutItem = new ShortcutItem("shortcutProcessing", AgentConstants.QUERY_TAG_1, AgentConstants.QUERY_TAG_2, "", "");

            shortcutItem.OutputAction = new OutputAction("", "");


            shortcutDialogue.DialogueItemList.Add(shortcutItem);

            agent.DialogueList.Add(shortcutDialogue);
        }
Exemplo n.º 3
0
        public static void OpenProgramParent(ShortcutItem item)
        {
            string strCurrentShortcutName = item.Text;
            string strCurrentShortcutPath = item.Application;

            OpenProgramParent(strCurrentShortcutPath);
        }
Exemplo n.º 4
0
        internal CustomShortcut(
            string shortcutName,
            string targetPath,
            string targetArguments,
            CustomShortcutType shortcutType,
            WindowType windowType,
            string shortcutRootFolder,
            string basicIconToUse = null,
            string workingFolder  = null
            )
        {
            var vbsFolderPath =
                DirectoryUtils.GetUniqueDirName(CustomShortcutGetters.CustomShortcutVbsPath + shortcutName) + "\\";
            var shortcutPath = $"{shortcutRootFolder}{new DirectoryInfo(vbsFolderPath).Name}\\{shortcutName}.lnk";


            ShortcutName    = shortcutName.CleanInvalidFilenameChars();
            ShortcutItem    = new ShortcutItem(shortcutPath);
            TargetPath      = targetPath;
            TargetArguments = targetArguments;
            ShortcutType    = shortcutType;
            VbsFolderPath   = vbsFolderPath;
            WorkingFolder   = workingFolder;
            WindowType      = windowType;

            Directory.CreateDirectory(VbsFolderPath);

            if (basicIconToUse != null && File.Exists(basicIconToUse))
            {
                BasicShortcutIcon = basicIconToUse;
            }
        }
Exemplo n.º 5
0
        public static void ExecuteProgram(ShortcutItem shortcutItem)
        {
            //Exit if empty
            if (shortcutItem == null)
            {
                return;
            }

            string strApplicationToExecute = shortcutItem.Application;

            if (System.IO.File.Exists(GetApplicationPart(strApplicationToExecute)) || System.IO.Directory.Exists(GetApplicationPart(strApplicationToExecute)))
            {
                //Try to execute file
                try
                {
                    string strExecutable = GetApplicationPart(strApplicationToExecute);
                    string strArgs       = shortcutItem.Arguments;               //GetArgumentPart(strApplicationToExecute);

                    System.Diagnostics.Process p         = new System.Diagnostics.Process();
                    ProcessStartInfo           StartInfo = new System.Diagnostics.ProcessStartInfo(strExecutable, strArgs);

                    if (shortcutItem.RunAsAdmin)
                    {
                        StartInfo.UseShellExecute = true;
                        StartInfo.Verb            = "runas";

                        if (System.IO.Directory.Exists(strExecutable))
                        {
                            //directory... use explorer
                            string windows  = Environment.GetEnvironmentVariable("windir");
                            string explorer = Path.Combine(windows, "explorer.exe");

                            StartInfo.Arguments = StartInfo.FileName;
                            StartInfo.FileName  = explorer;
                        }
                        else if (!IsExecutable(strExecutable))
                        {
                            MessageBox.Show("Unable to run program as Administrator.");
                            return;
                        }
                    }

                    if (System.IO.File.Exists(strExecutable))
                    {
                        StartInfo.WorkingDirectory = System.IO.Directory.GetParent(strExecutable).FullName;
                    }

                    p.StartInfo = StartInfo;
                    p.Start();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            else
            {
                MessageBox.Show("Application/Directory does not exists.\nPlease ensure that the folder/executable exist.");
            }
        }
        /// <summary>
        ///
        /// </summary>
        private void ContextMenuOpening(Object sender, EventArgs e)
        {
            Boolean customShortcut = false;

            if (this.listView.SelectedItems.Count > 0)
            {
                ShortcutItem current = this.listView.SelectedItems[0].Tag as ShortcutItem;
                this.removeShortcut.Enabled  = current.Custom != Keys.None;
                this.revertToDefault.Enabled = current.Custom != current.Default;
            }
            else
            {
                this.removeShortcut.Enabled = revertToDefault.Enabled = false;
            }
            foreach (ListViewItem item in listView.Items)
            {
                ShortcutItem current = item.Tag as ShortcutItem;
                if (current.Custom != current.Default)
                {
                    customShortcut = true;
                    break;
                }
            }
            this.revertAllToDefault.Enabled = customShortcut;
        }
Exemplo n.º 7
0
 /// <summary>
 /// Assign a new valid shortcut when keys are pressed
 /// </summary>
 private void ListViewKeyDown(Object sender, KeyEventArgs e)
 {
     if (this.listView.SelectedItems.Count > 0)
     {
         if (e.KeyData == Keys.Delete)
         {
             this.RemoveShortcutClick(null, null);
         }
         else
         {
             ListViewItem selected = this.listView.SelectedItems[0];
             ShortcutItem item     = selected.Tag as ShortcutItem;
             if (item.Custom != e.KeyData && ToolStripManager.IsValidShortcut(e.KeyData))
             {
                 selected.SubItems[1].Text = GetKeysAsString(e.KeyData);
                 item.Custom = e.KeyData; selected.Selected = true;
                 this.UpdateItemHighlightFont(selected, item);
                 if (this.CountItemsByKey(e.KeyData) > 1)
                 {
                     String message = TextHelper.GetString("Info.ShortcutIsAlreadyUsed");
                     ErrorManager.ShowWarning(message, null);
                     this.filterTextBox.Focus(); // Set focus to filter...
                     this.filterTextBox.Text = GetKeysAsString(e.KeyData);
                     this.filterTextBox.SelectAll();
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
        internal CustomShortcut(
            string shortcutName,
            string targetPath,
            string targetArguments,
            CustomShortcutType shortcutType,
            WindowType windowType,
            string shortcutRootFolder,
            string basicIconToUse = null,
            string workingFolder = null
            )
        {
            var vbsFolderPath =
                DirectoryUtils.GetUniqueDirName(CustomShortcutGetters.CustomShortcutVbsPath + shortcutName) + "\\";
            var shortcutPath = $"{shortcutRootFolder}{new DirectoryInfo(vbsFolderPath).Name}\\{shortcutName}.lnk";


            ShortcutName = shortcutName.CleanInvalidFilenameChars();
            ShortcutItem = new ShortcutItem(shortcutPath);
            TargetPath = targetPath;
            TargetArguments = targetArguments;
            ShortcutType = shortcutType;
            VbsFolderPath = vbsFolderPath;
            WorkingFolder = workingFolder;
            WindowType = windowType;

            Directory.CreateDirectory(VbsFolderPath);

            if (basicIconToUse != null && File.Exists(basicIconToUse)) BasicShortcutIcon = basicIconToUse;
        }
Exemplo n.º 9
0
        protected override void PreInit()
        {
            base.PreInit();
            for (int i = 0; i < 8; i++)
            {
                UISprite      _icon   = FindUIObject <UISprite>("Icon" + (i + 1));
                UISprite      _mark   = FindUIObject <UISprite>("Button" + (i + 1) + "Mark");
                UIImageButton _button = FindUIObject <UIImageButton>("Button" + (i + 1));
                Transform     _frame  = FindUIObject <Transform>("Frame" + (i + 1));
                _mark.type          = UISprite.Type.Filled;
                _mark.fillDirection = UISprite.FillDirection.Radial360;
                _icon.fillAmount    = 1f;

                ShortcutItem _shortcut = _icon.gameObject.AddComponent <ShortcutItem>();
                _shortcut.icon   = _icon;
                _shortcut.index  = i;
                _shortcut.mark   = _mark;
                _shortcut.button = _button;
                shortcuts[i]     = _shortcut;
            }


            shortcuts[0].keyCode = KeyCode.Alpha1;
            shortcuts[1].keyCode = KeyCode.Alpha2;
            shortcuts[2].keyCode = KeyCode.Alpha3;
            shortcuts[3].keyCode = KeyCode.Alpha4;

            shortcuts[4].keyCode = KeyCode.Alpha5;
            shortcuts[5].keyCode = KeyCode.Alpha6;
            shortcuts[6].keyCode = KeyCode.Alpha7;
            shortcuts[7].keyCode = KeyCode.Alpha8;
        }
Exemplo n.º 10
0
        private void RemoveInvalidEntries()
        {
            List <string> groupNames = ShortcutUtil.GetShortcutGroupNames();

            foreach (string groupName in groupNames)
            {
                bool updated = false;
                List <ShortcutItem> shortcuts = ShortcutUtil.GetShortcuts(groupName);
                for (int i = shortcuts.Count - 1; i >= 0; i--)
                {
                    ShortcutItem item        = shortcuts[i];
                    string       application = item.Application;
                    string       txt         = item.Text;
                    if (!System.IO.Directory.Exists(application) && !System.IO.File.Exists(application))
                    {
                        //invalid
                        WriteLine(string.Format("removing: {0}", txt));
                        WriteLine(string.Format("   {0}", application));
                        shortcuts.RemoveAt(i);
                        updated = true;
                    }
                }

                //update shortcuts if necessary
                if (updated)
                {
                    ShortcutUtil.UpdateGroupShortcut(groupName, shortcuts.ToArray());
                }
            }
        }
        public static bool DeleteShortcut(string groupName, params ShortcutItem[] shortcutsToDelete)
        {
            if (shortcutsToDelete == null)
            {
                return(false);
            }
            if (shortcutsToDelete.Length == 0)
            {
                return(false);
            }

            List <ShortcutItem> items = GetShortcuts(groupName);

            foreach (ShortcutItem toDelete in shortcutsToDelete)
            {
                for (int i = items.Count - 1; i > 0; i--)
                {
                    ShortcutItem item = items[i];
                    if (item.Id == toDelete.Id)
                    {
                        items.RemoveAt(i);
                        break;
                    }
                }
            }
            UpdateGroupShortcut(groupName, items.ToArray());
            return(true);
        }
Exemplo n.º 12
0
        private void InitDatas()
        {
            {
                ShortcutItem scItem = new ShortcutItem();
                scItem.Index     = 0;
                scItem.ItemCfgID = 1;
                scItem.Count     = 1;

                ItemOnShortcut.Add(scItem);
            }

            {
                ShortcutItem scItem = new ShortcutItem();
                scItem.Index     = 1;
                scItem.ItemCfgID = 2;
                scItem.Count     = 1;

                ItemOnShortcut.Add(scItem);
            }

            {
                ShortcutItem scItem = new ShortcutItem();
                scItem.Index     = 4;
                scItem.ItemCfgID = 2;
                scItem.Count     = 1;

                ItemOnShortcut.Add(scItem);
            }
        }
Exemplo n.º 13
0
        //Adds shortcut into the listview
        private void AddItem(ShortcutItem item)
        {
            Icon icn = null;

            //Load icon from path. If empty, try use the icons in the mappings
            if (string.IsNullOrEmpty(item.IconPath))
            {
                string strApplicationPart = CommonUtil.GetApplicationPart(item.Application);

                if (System.IO.Directory.Exists(strApplicationPart))
                {
                    //folder
                    icn = IconMapperUtil.GetDefaultIcon("folder");
                }
                else
                {
                    //get the default icons
                    string strExt = System.IO.Path.GetExtension(strApplicationPart).ToLower();
                    icn = IconMapperUtil.GetDefaultIcon(strExt);
                }
            }
            else
            {
                //Find in the icon folder first. if it exists, use it
                if (System.IO.File.Exists(AppConfig.GetIconMapFile(item.IconPath)))
                {
                    icn = CommonUtil.GetIcon(AppConfig.GetIconMapFile(item.IconPath));
                }

                //Locate the physical file directly. If exists, use it
                else if (System.IO.File.Exists(item.IconPath))
                {
                    icn = CommonUtil.GetIcon(item.IconPath);
                }

                //Use default icon
                else
                {
                    string strExt = System.IO.Path.GetExtension(item.Application).ToLower();
                    icn = IconMapperUtil.GetDefaultIcon(strExt);
                }
            }

            //Add item to list so that it is viewable in the list
            imageList1.Images.Add(icn);

            //create listview item
            ListViewItem l = new ListViewItem();

            l.ImageIndex  = imageList1.Images.Count - 1;
            l.Text        = item.Text; // +"\n" + item.strApplication;
            l.Name        = Guid.NewGuid().ToString();
            l.ToolTipText = item.Application;
            l.Tag         = item;
            l.Group       = lvSearchResult.Groups[item.GroupName];

            //Add list view item
            lvSearchResult.Items.Add(l);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Revert the selected items shortcut to default
        /// </summary>
        private void RevertToDefault(ListViewItem listItem)
        {
            ShortcutItem item = listItem.Tag as ShortcutItem;

            listItem.SubItems[1].Text = this.GetKeysAsString(item.Default);
            item.Custom = item.Default;
            this.UpdateItemHighlightFont(listItem, item);
        }
Exemplo n.º 15
0
 private void UpdatePictureBoxOverlay(PannablePictureBox pannablePictureBox, ShortcutItem currentShortcutItem)
 {
     pannablePictureBox.ShowTextOverlay  = currentShortcutItem.Properties.CurrentState.ShowNameOnSquare150X150Logo;
     pannablePictureBox.TextOverlayColor = currentShortcutItem.Properties.CurrentState.ForegroundText == "light"
         ? Color.White
         : Color.Black;
     pannablePictureBox.TextOverlay = Path.GetFileNameWithoutExtension(currentShortcutItem.ShortcutFileInfo.Name);
 }
Exemplo n.º 16
0
 private bool OnFilter(ShortcutItem item)
 {
     if (Filter.IsNullOrEmpty() || item == null)
     {
         return(true);
     }
     return(Regex.IsMatch(item.ToString(), Filter, RegexOptions.IgnoreCase));
 }
Exemplo n.º 17
0
        private void JumpToShortcutItem(ShortcutItem shortcutItem)
        {
            var shortcutListViewItem =
                _shortcutsList.First(s => s.ShortcutItem.ShortcutFileInfo.FullName == shortcutItem.ShortcutFileInfo.FullName);
            var itemInListView = srtlstShortcuts.Items[srtlstShortcuts.Items.IndexOf(shortcutListViewItem)];

            itemInListView.Selected = true;
            itemInListView.EnsureVisible();
        }
Exemplo n.º 18
0
        public ShortcutItemConfiguration(ShortcutItem shortcut)
            : this()
        {
            this.Shortcut = shortcut;

            cbRequirePreview.Checked = shortcut.RequirePreviewOpen;

            UpdateShortcutDisplay();
            UpdateActionChain();
        }
Exemplo n.º 19
0
        public ShortcutItemConfiguration(ShortcutItem shortcut)
            : this()
        {
            this.Shortcut = shortcut;

            cbRequirePreview.Checked = shortcut.RequirePreviewOpen;

            UpdateShortcutDisplay();
            UpdateActionChain();
        }
Exemplo n.º 20
0
        private void btnGotoShortcut_Click(object sender, EventArgs e)
        {
            if (lstCustomShortcuts.SelectedItems.Count == 0)
            {
                return;
            }

            GotoShortcutItem = ((CustomShortcutListViewItem)lstCustomShortcuts.SelectedItems[0]).CustomShortcut.ShortcutItem;
            Close();
        }
Exemplo n.º 21
0
 /// <summary>
 /// Creates a new instance of <see cref="ShortcutListItem"/> with an associated <see cref="ShortcutItem"/>.
 /// </summary>
 public ShortcutListItem(ShortcutItem shortcutItem)
 {
     this.item       = shortcutItem;
     this.conflicts  = null;
     this.custom     = this.Item.Custom;
     this.KeysString = DataConverter.KeysToString(this.Custom);
     this.Name       = this.Text = this.Id;
     this.SubItems.Add(this.KeysString);
     UpdateItemHighlightFont(this);
 }
Exemplo n.º 22
0
        private void loadData()
        {
            var temp = ShortcutAutoSave.LoadData();

            if (temp == null)
            {
                temp = new ShortcutItem[0];
            }
            Scheme = temp;
        }
Exemplo n.º 23
0
 public void UpdateShortcuts(IEnumerable <ShortcutItem> sItems)
 {
     if (sItems == null)
     {
         sItems = new ShortcutItem[0];
     }
     ShortcutAutoSave.SaveData(sItems.ToList());
     Scheme = null;
     OnDataChanged();
 }
Exemplo n.º 24
0
    protected override void BuildItems()
    {
        base.BuildItems();

        for (int i = 0; i < items.Length; i++)
        {
            GameObject _uiItemObj = new GameObject("UIItem_" + items[i]._Label);
            _uiItemObj.transform.SetParent(_uiLayerObj.transform, false);

            if (_sSettings.Direction == StickShortcutDirection.Horizontal)
            {
                _uiItemObj.transform.localPosition = new Vector3(_sSettings.ItemWidth * i, 0, 0);
            }
            else if (_sSettings.Direction == StickShortcutDirection.Vertical)
            {
                _uiItemObj.transform.localPosition = new Vector3(0, -_sSettings.ItemWidth * i, 0);
            }
            items[i].Layer = gameObject.GetComponent <ShortcutItemLayer>();
            items[i].Build(_sSettings, _uiItemObj);
        }


        if (_curLevel > 1)           // in case parent item, draw cancel button
        {
            GameObject uiCancelItemObj = new GameObject("UIItem_Cancel");
            uiCancelItemObj.transform.SetParent(_uiLayerObj.transform, false);

            if (_sSettings.Direction == StickShortcutDirection.Horizontal)
            {
                uiCancelItemObj.transform.localPosition = new Vector3(_sSettings.ItemWidth * items.Length, 0, 0);
            }
            else if (_sSettings.Direction == StickShortcutDirection.Vertical)
            {
                uiCancelItemObj.transform.localPosition = new Vector3(0, -_sSettings.ItemWidth * items.Length, 0);
            }

            ShortcutItem cancelItem = uiCancelItemObj.AddComponent <ShortcutItem>();
            cancelItem.Layer        = gameObject.GetComponent <ShortcutItemLayer>();
            cancelItem._Label       = _cancelItemLabel;
            cancelItem._ItemType    = ItemType.NormalButton;
            cancelItem.IsCancelItem = true;

            cancelItem.Build(_sSettings, uiCancelItemObj);

            ShortcutItem[] newItems = new ShortcutItem[items.Length + 1];

            for (int i = 0; i < items.Length; i++)
            {
                newItems[i] = items[i];
            }
            newItems[items.Length] = cancelItem;

            items = newItems;
        }
    }
Exemplo n.º 25
0
 /// <summary>
 /// Removes the shortcut by setting it to Keys.None
 /// </summary>
 private void RemoveShortcutClick(Object sender, EventArgs e)
 {
     if (this.listView.SelectedItems.Count > 0)
     {
         ListViewItem selected = this.listView.SelectedItems[0];
         ShortcutItem item     = selected.Tag as ShortcutItem;
         selected.SubItems[1].Text = GetKeysAsString(Keys.None);
         item.Custom = Keys.None;
         this.UpdateItemHighlightFont(selected, item);
     }
 }
        private void JumpToShortcutItem(ShortcutItem shortcutItem)
        {
            UpdateFilteredList(true);
            var shortcutListViewItem =
                srtlstShortcuts.Items.Cast <ShortcutItemListViewItem>().First(
                    s => s.ShortcutItem.ShortcutFileInfo.FullName == shortcutItem.ShortcutFileInfo.FullName);
            var itemInListView = srtlstShortcuts.Items[srtlstShortcuts.Items.IndexOf(shortcutListViewItem)];

            itemInListView.Selected = true;
            itemInListView.EnsureVisible();
        }
Exemplo n.º 27
0
 public static Task <List <ShortcutItem> > GetShortcutItems([NotNull] IEnumerable <FileInfo> xmlFiles)
 {
     return(Task.Run(() =>
     {
         return xmlFiles.Select(s =>
         {
             var item = new ShortcutItem(s);
             return item;
         }).ToList();
     }));
 }
Exemplo n.º 28
0
        public static void CheckRelSourcePath(ShortcutItem item, string relPathFromProjDir, string prefix)
        {
            var sourceDir = Path.GetDirectoryName(item.SourceDwg);
            var relDir    = Path.Combine(item.Project.Dir, relPathFromProjDir);

            if (!Path.GetFullPath(sourceDir).EqualsIgnoreCase(Path.GetFullPath(relDir)))
            {
                var fixDir  = Path.Combine(MainVM.MainVm.ShortcutFolder, item.Project.Name, relPathFromProjDir);
                var fixPath = Path.Combine(fixDir, Path.GetFileName(item.SourceDwg));
                var msg     = $"{prefix} должна лежать в папке '{fixDir}'.";
                item.Status.Add(State.Error(item, item.Project, msg, msg, true, s => Fix.FixPath(item, fixPath, s)));
            }
        }
Exemplo n.º 29
0
        private void FixCmdExec(ShortcutItem item)
        {
            var msg = string.Empty;

            foreach (var state in item.Status.Where(w => w.Fix != null))
            {
                var s = state.Msg;
                state.Fix(state);
                msg += $"Исправлено: {s}\n\r";
            }

            ShowMessage(msg.IsNullOrEmpty() ? "Ничего не исправлено." : msg);
        }
Exemplo n.º 30
0
        public void OnAddItem(ShortcutItem item)
        {
            Sprite sp = IconsAssetHolder.Instance.GetIconByID(item.ItemCfgID);

            if (!System.Object.ReferenceEquals(null, sp))
            {
                BtnList[item.Index].sprite = sp;

                Config.IconsConfig icon = ConfigDataMgr.Instance.IconCfgLoader.GetDataByID(item.ItemCfgID);

                Texts[item.Index].text = icon.Name;
            }
        }
Exemplo n.º 31
0
        /// <summary>
        /// Gets the count of items with the specified keys
        /// </summary>
        private Int32 CountItemsByKey(Keys keys)
        {
            Int32 counter = 0;

            foreach (ListViewItem item in this.listView.Items)
            {
                ShortcutItem si = item.Tag as ShortcutItem;
                if (si.Custom == keys)
                {
                    counter++;
                }
            }
            return(counter);
        }
Exemplo n.º 32
0
 /// <summary>
 /// Loads the shortcuts from a file
 /// </summary>
 public void LoadShortcuts(string file)
 {
     if (File.Exists(file))
     {
         List<Argument> shortcuts = new List<Argument>();
         shortcuts = (List<Argument>)ObjectSerializer.Deserialize(file, shortcuts, false);
         ClearShortcuts();
         foreach (Argument arg in shortcuts)
         {
             ShortcutItem item = GetRegisteredItem(arg.Key);
             if (item != null) item.Custom = (Keys)Enum.Parse(typeof(Keys), arg.Value);
         }
     }
 }
Exemplo n.º 33
0
	protected override void BuildItems() {
		base.BuildItems ();
		
		for (int i=0; i<items.Length; i++) {
			GameObject _uiItemObj = new GameObject("UIItem_"+items[i]._Label);
			_uiItemObj.transform.SetParent(_uiLayerObj.transform, false);

			if (_sSettings.Direction == StickShortcutDirection.Horizontal) {
				_uiItemObj.transform.localPosition = new Vector3(_sSettings.ItemWidth*i, 0, 0);
			}
			else if (_sSettings.Direction == StickShortcutDirection.Vertical) {
				_uiItemObj.transform.localPosition = new Vector3(0, -_sSettings.ItemWidth*i, 0);
			}
			items[i].Layer = gameObject.GetComponent<ShortcutItemLayer>();
			items[i].Build(_sSettings, _uiItemObj);
		}


		if (_curLevel > 1) { // in case parent item, draw cancel button
			GameObject uiCancelItemObj = new GameObject("UIItem_Cancel");
			uiCancelItemObj.transform.SetParent (_uiLayerObj.transform, false);

			if (_sSettings.Direction == StickShortcutDirection.Horizontal) {
				uiCancelItemObj.transform.localPosition = new Vector3(_sSettings.ItemWidth*items.Length, 0, 0);
			}
			else if (_sSettings.Direction == StickShortcutDirection.Vertical) {
				uiCancelItemObj.transform.localPosition = new Vector3(0, -_sSettings.ItemWidth*items.Length, 0);
			}

			ShortcutItem cancelItem = uiCancelItemObj.AddComponent<ShortcutItem>();
			cancelItem.Layer = gameObject.GetComponent<ShortcutItemLayer>();
			cancelItem._Label = _cancelItemLabel;
			cancelItem._ItemType = ItemType.NormalButton;
			cancelItem.IsCancelItem = true;
			
			cancelItem.Build (_sSettings, uiCancelItemObj);         

			ShortcutItem[] newItems = new ShortcutItem[items.Length+1];
			
			for (int i=0; i<items.Length; i++) {
				newItems[i] = items[i];
			}
			newItems[items.Length] = cancelItem;
			
			items = newItems;
		}

	}
Exemplo n.º 34
0
	protected override void BuildItems() {
		base.BuildItems ();

		for (int i=0; i<items.Length; i++) {
			GameObject _uiItemObj = new GameObject("UIItem_"+items[i]._Label);
			_uiItemObj.transform.SetParent(_uiLayerObj.transform, false);
			
			_uiItemObj.transform.localRotation = Quaternion.Euler (0, _sSettings.EachItemDegree*i, 0);

			items[i].Layer = gameObject.GetComponent<ShortcutItemLayer>();
			items[i].Build(_sSettings, _uiItemObj);
		}
		
		if (_curLevel > 1) { // in case parent item, draw cancel button
			GameObject uiCancelItemObj = new GameObject("UIItem_Cancel");
			uiCancelItemObj.transform.SetParent (_uiLayerObj.transform, false);
			uiCancelItemObj.transform.localRotation = Quaternion.Euler (0, _sSettings.EachItemDegree*items.Length, 0);
			
			ShortcutItem cancelItem = uiCancelItemObj.AddComponent<ShortcutItem>();

			cancelItem.Layer = gameObject.GetComponent<ShortcutItemLayer>();
			cancelItem._Label = _cancelItemLabel;
			cancelItem._ItemType = ItemType.NormalButton;
			cancelItem.IsCancelItem = true;
			
			cancelItem.Build (_sSettings, uiCancelItemObj);    

			ShortcutItem[] newItems = new ShortcutItem[items.Length+1];

			for (int i=0; i<items.Length; i++) {
				newItems[i] = items[i];
			}
			newItems[items.Length] = cancelItem;

			items = newItems;

		}
	}
 private void JumpToShortcutItem(ShortcutItem shortcutItem)
 {
     UpdateFilteredList(true);
     var shortcutListViewItem =
         srtlstShortcuts.Items.Cast<ShortcutItemListViewItem>().First(
             s => s.ShortcutItem.ShortcutFileInfo.FullName == shortcutItem.ShortcutFileInfo.FullName);
     var itemInListView = srtlstShortcuts.Items[srtlstShortcuts.Items.IndexOf(shortcutListViewItem)];
     itemInListView.Selected = true;
     itemInListView.EnsureVisible();
 }
        private void btnGotoShortcut_Click(object sender, EventArgs e)
        {
            if (lstCustomShortcuts.SelectedItems.Count == 0)
                return;

            GotoShortcutItem =
                ((CustomShortcutListViewItem) lstCustomShortcuts.SelectedItems[0]).CustomShortcut.ShortcutItem;
            Close();
        }
Exemplo n.º 37
0
 public TileIcon(ShortcutItem shortcutItem)
 {
     _shortcutItem = shortcutItem;
 }
Exemplo n.º 38
0
 private void UpdatePictureBoxOverlay(PannablePictureBox pannablePictureBox, ShortcutItem currentShortcutItem)
 {
     pannablePictureBox.ShowTextOverlay = currentShortcutItem.Properties.CurrentState.ShowNameOnSquare150X150Logo;
     pannablePictureBox.OverlayColor = currentShortcutItem.Properties.CurrentState.ForegroundText == "light"
         ? Color.White
         : Color.Black;
     pannablePictureBox.TextOverlay = Path.GetFileNameWithoutExtension(currentShortcutItem.ShortcutFileInfo.Name);
 }
	void OnEnable() {
		_sItem = target as ShortcutItem;
	}
        /// <summary>
        ///     Gather a list of ShortcutItems from the current environment
        /// </summary>
        /// <returns></returns>
        public static List<ShortcutItem> GetShortcuts(bool refreshCache = false)
        {
            if (refreshCache)
                _shortcutsCache = null;

            if (_shortcutsCache != null)
                return _shortcutsCache;

            var shortcutsList = new List<ShortcutItem>();

            var pathsToScan = new List<string>
            {
                @"%PROGRAMDATA%\Microsoft\Windows\Start Menu",
                @"%APPDATA%\Microsoft\Windows\Start Menu"
            };

            foreach (var pathToScan in pathsToScan)
            {
                //Recursively go through all folders of lnk files, adding each ShortcutItem to the list
                Action<string, Action<string>> applyAllFiles = null;
                applyAllFiles = (folder, fileAction) =>
                {
                    foreach (var file in Directory.GetFiles(folder)) fileAction(file);
                    foreach (var subDir in Directory.GetDirectories(folder))
                        try
                        {
                            applyAllFiles(subDir, fileAction);
                        }
                        catch
                        {
                            // ignored
                        }
                };

                applyAllFiles(Environment.ExpandEnvironmentVariables(pathToScan), f =>
                {
                    var extension = Path.GetExtension(f);
                    if (extension != null && !extension.Equals(".lnk", StringComparison.OrdinalIgnoreCase))
                        return;

                    var shortcutItem = new ShortcutItem(f);
                    if (shortcutItem.IsValidForIconification)
                        shortcutsList.Add(shortcutItem);
                });
            }

            //Order the list by name
            _shortcutsCache = shortcutsList.OrderBy(f => f.ShortcutFileInfo.Name).ToList();


            return _shortcutsCache;
        }
 public ShortcutItemListViewItem(ShortcutItem shortcutItem)
 {
     ShortcutItem = shortcutItem;
     UpdateColumns();
 }