Example #1
0
        private void ItemUpload_Click(object sender, EventArgs e)
        {
            string[] args = SelectedItemPaths.ToArray();

            if (CheckIfRunning())
            {
                SendMessage(args);
            }
            else
            {
                StartServer(args);
            }
        }
Example #2
0
        async Task Sync()
        {
            await _helper.HandleSyncRunning().ConfigureAwait(false);

            var folderPaths = SelectedItemPaths.ToList();
            var result      = _helper.TryGetInfo(folderPaths).Result;

            foreach (var r in result)
            {
                _helper.OpenUrl("http://withsix.com/p/Arma-3/mods/" + new ShortGuid(r.ContentInfo.ContentId) +
                                "?upload=1");
            }
        }
        protected override bool CanShowMenu()
        {
            using (var e = SelectedItemPaths.GetEnumerator())
            {
                if (!e.MoveNext())
                {
                    return(false);
                }

                var firstItem = e.Current;
                return(firstItem.EndsWith(".exe") || firstItem.EndsWith(".dll"));
            }
        }
Example #4
0
        protected override bool CanShowMenu()
        {
            List <string> selectionSet = SelectedItemPaths.ToList();

            if (selectionSet.Count != 1)
            {
                return(false);
            }

            var result = GetConfig().Any(i => i.Path == selectionSet.First());

            return(result);
        }
Example #5
0
 private void CopyPathURLMethod()
 {
     Clipboard.Clear();
     string[] array = SelectedItemPaths.Cast <string>().ToArray();
     try
     {
         Clipboard.SetText(new Uri(array.ToStringArray(false)).AbsoluteUri);
     }
     catch (Exception ex)
     {
         EasyLogger.Error(ex);
     }
 }
        private void LaunchGUITool(object sender, EventArgs e)
        {
            var srcPath = SelectedItemPaths.ElementAtOrDefault(0);
            var dstPath = SelectedItemPaths.ElementAtOrDefault(1);

            var arg = !string.IsNullOrEmpty(srcPath) ? $"-s \"{srcPath}\" " : string.Empty;

            arg += !string.IsNullOrEmpty(dstPath) ? $"-d \"{dstPath}\" " : string.Empty;

            string exePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ExcelMerge.GUI.exe");

            System.Diagnostics.Process.Start(exePath, arg);
        }
 // <summary>
 // Determines whether the menu item can be shown for the selected item.
 // </summary>
 // <returns>
 //   <c>true</c> if item can be shown for the selected item for this instance.; otherwise, <c>false</c>.
 // </returns>
 protected override bool CanShowMenu()
 {
     //  We can show the item only for a single selection.
     if (SelectedItemPaths.Count() == 1)
     {
         this.UpdateMenu();
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #8
0
        /// <summary>
        /// Creates the context menu. This can be a single menu item or a tree of them.
        /// </summary>
        /// <returns>
        /// The context menu for the shell context menu.
        /// </returns>
        protected override ContextMenuStrip CreateMenu()
        {
            //  Create the menu strip.
            var menu = new ContextMenuStrip();

            //  Create a menu item to hold all of the subitems.
            var advancedItem = new ToolStripMenuItem
            {
                Text  = "Advanced",
                Image = Properties.Resources.Copy
            };

            //  Now add the child items.
            var readOnlyItem = new ToolStripMenuItem
            {
                Text    = "Read Only",
                Checked = File.GetAttributes(SelectedItemPaths.First()).HasFlag(FileAttributes.ReadOnly)
            };

            readOnlyItem.Click += (sender, args) => DoToggleReadOnly();

            //  Add the touch item.
            var touchItem = new ToolStripMenuItem
            {
                Text    = "Touch",
                Enabled = !File.GetAttributes(SelectedItemPaths.First()).HasFlag(FileAttributes.ReadOnly)
            };

            touchItem.Click += (sender, args) => DoTouch();

            var copyPathItem = new ToolStripMenuItem
            {
                Text  = "Copy Path",
                Image = Properties.Resources.Copy
            };

            copyPathItem.Click += (sender, args) => DoCopyPath();

            //  Add the items.
            advancedItem.DropDownItems.Add(readOnlyItem);
            advancedItem.DropDownItems.Add(touchItem);
            advancedItem.DropDownItems.Add(new ToolStripSeparator());
            advancedItem.DropDownItems.Add(copyPathItem);

            //  Add the item to the context menu.
            menu.Items.Add(advancedItem);

            //  Return the menu.
            return(menu);
        }
        private uint ParseSteamAppId()
        {
            try
            {
                var fileAddress = SelectedItemPaths.FirstOrDefault();

                if (!string.IsNullOrWhiteSpace(fileAddress) &&
                    File.Exists(fileAddress) &&
                    new FileInfo(fileAddress).Length < 1024)
                {
                    var fileContent = File.ReadAllText(fileAddress);

                    if (!fileContent.Contains(@"[InternetShortcut]"))
                    {
                        return(0);
                    }

                    var steamUrlPattern = @"steam://rungameid/";
                    var urlIndex        = fileContent.IndexOf(steamUrlPattern, StringComparison.InvariantCultureIgnoreCase);

                    if (urlIndex < 0)
                    {
                        return(0);
                    }

                    var nextLine = fileContent.IndexOf(@"\r", urlIndex + steamUrlPattern.Length,
                                                       StringComparison.InvariantCultureIgnoreCase);

                    if (nextLine < 0)
                    {
                        nextLine = fileContent.Length - 1;
                    }

                    var appIdString = fileContent.Substring(urlIndex + steamUrlPattern.Length,
                                                            nextLine - urlIndex - steamUrlPattern.Length);
                    uint appId;

                    if (uint.TryParse(appIdString, out appId))
                    {
                        return(appId);
                    }
                }
            }
            catch
            {
                // ignored
            }

            return(0);
        }
        private void CopyFile()
        {
            try
            {
                if (!SelectedItemPaths.Any())
                {
                    return;
                }

                var location = new Uri(Assembly.GetExecutingAssembly().CodeBase);

                var info = new FileInfo(location.AbsolutePath).Directory;

                var json = File.ReadAllText(info.FullName + @"\config.json");

                var objConfig = (Config)JsonConvert.DeserializeObject(json, typeof(Config));

                var client = new RestClient($"{objConfig.Url}/api/clipboard")
                {
                    UserAgent = "Sia-Agent"
                };

                var request = new RestRequest()
                {
                    Method        = Method.POST,
                    RequestFormat = DataFormat.Json
                };

                request.AddJsonBody(SelectedItemPaths.First());

                var response = client.Execute(request);

                switch (response.StatusCode)
                {
                case System.Net.HttpStatusCode.OK:
                    MessageBox.Show("File Copied");
                    break;

                default:
                    MessageBox.Show("Copy Failed :" + response.StatusCode);
                    break;
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "ERROR");
            }
        }
Example #11
0
        protected override ContextMenuStrip CreateMenu()
        {
            var menu = new ContextMenuStrip();

            var archiveDirectory = new ToolStripMenuItem
            {
                Text = "Pack this Directory"
            };

            var fileList = SelectedItemPaths.ToList();

            var archiveDirectoryToBeatmapFile = new ToolStripMenuItem
            {
                Text = "Pack this Directory to " + new DirectoryInfo(fileList[0]).Name + ".osz"
            };

            var archiveDirectoryToSkinFile = new ToolStripMenuItem
            {
                Text = "Pack this Directory to " + new DirectoryInfo(fileList[0]).Name + ".osk"
            };

            archiveDirectory.Click += (sender, args) =>
            {
                debugMessage();

                runAppWithArgs(getAppPath() + "osuFileArchiver.exe", String.Format("--directoryLocation \"{0}\" --saveLocation \"{1}\"", fileList[0], fileList[0] + ".osz"));
            };

            archiveDirectoryToBeatmapFile.Click += (sender, args) =>
            {
                debugMessage();

                runAppWithArgs(getAppPath() + "osuFileArchiver.exe", String.Format("--directoryLocation \"{0}\" --saveLocation \"{1}\" --skipMenu", fileList[0], fileList[0] + ".osz"));
            };

            archiveDirectoryToSkinFile.Click += (sender, args) =>
            {
                debugMessage();

                runAppWithArgs(getAppPath() + "osuFileArchiver.exe", String.Format("--directoryLocation \"{0}\" --saveLocation \"{1}\" --skipMenu", fileList[0], fileList[0] + ".osk"));
            };

            menu.Items.Add(archiveDirectory);
            menu.Items.Add(archiveDirectoryToBeatmapFile);
            menu.Items.Add(archiveDirectoryToSkinFile);

            return(menu);
        }
Example #12
0
        private void CopyWslPathToClipboard()
        {
            if (!SelectedItemPaths.Any())
            {
                return;
            }

            try
            {
                Clipboard.SetText(GetWslPath(SelectedItemPaths.First()));
            }
            catch
            {
                // die silently
            }
        }
Example #13
0
        protected override bool CanShowMenu()
        {
            try {
                if (SelectedItemPaths.Count() != 1)
                {
                    return(false);
                }

                var client = Novaroma.Helper.CreateShellServiceClient(TimeSpan.FromMilliseconds(50));
                client.Test();
                return(true);
            }
            catch {
                return(false);
            }
        }
Example #14
0
        private void ZipFile(bool encrypt)
        {
            try {
                if (SelectedItemPaths.Count() == 0)
                {
                    return;
                }

                string destination = this.GetZipFileNamePath(SelectedItemPaths.First());
                var    window      = new Compressor(destination, encrypt, SelectedItemPaths.ToArray());
                window.Show();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message, "ZipMagikLITE: Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        // ReSharper disable once FlagArgument
        private void BindTo(string networkInterfaceId, bool asAdmin)
        {
            try
            {
                var executableAddress = GetNetworkAdapterSelectorAddress();

                if (string.IsNullOrWhiteSpace(executableAddress))
                {
                    return;
                }

                // Executing the "NetworkAdapterSelector.Hook" and passing the address of executable file.
                var processInfo = new ProcessStartInfo(
                    executableAddress,
                    $"-n \"{networkInterfaceId}\" -e \"{SelectedItemPaths.First()}\""
                    )
                {
                    WindowStyle     = ProcessWindowStyle.Hidden,
                    CreateNoWindow  = true,
                    UseShellExecute = true
                };

                if (asAdmin)
                {
                    // Forcing administrator privileges
                    processInfo.Verb = @"runas";
                }

                Process.Start(processInfo);
            }
            catch (Exception e)
            {
                // Check if operation canceled by user
                if ((e as Win32Exception)?.NativeErrorCode == 1223)
                {
                    return;
                }

                // Otherwise, show an error message to the user
                MessageBox.Show(
                    e.ToString(),
                    Resources.DynamicMenuExtension_BindTo_Network_Adapter_Selector,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
            }
        }
        private ToolStripItem[] GetFileMenu()
        {
            if (SelectedItemPaths.Count() > 1)
            {
                var mItems = new List <ToolStripItem>
                {
                    new ToolStripMenuItem("Download Files", null, FileDownload),
                    new ToolStripMenuItem("Remove local contents", null, FileRemove),
                    new ToolStripMenuItem("Upload files", null, FileUpload)
                };
                return(mItems.ToArray());
            }

            if (SelectedItemPaths.Count() == 1)
            {
                var mItems = new List <ToolStripItem>();
                var file   = SelectedItemPaths.First();

                if (_fileStatus[file] == FileStatus.Directory)
                {
                    mItems.Add(new ToolStripMenuItem("Download Files", null, FileDownload));
                    mItems.Add(new ToolStripMenuItem("Remove local contents", null, FileRemove));
                    mItems.Add(new ToolStripMenuItem("Upload files", null, FileUpload));
                }

                if (_fileStatus[file] == FileStatus.InAnnex || _fileStatus[file] == FileStatus.InAnnexModified)
                {
                    mItems.Add(new ToolStripMenuItem("Download File", null, FileDownload));
                }

                if (_fileStatus[file] == FileStatus.OnDiskModified || _fileStatus[file] == FileStatus.Unknown)
                {
                    mItems.Add(new ToolStripMenuItem("Upload file", null, FileUpload));
                }

                if (_fileStatus[file] == FileStatus.OnDisk)
                {
                    mItems.Add(new ToolStripMenuItem("Remove local content", null, FileRemove));
                    mItems.Add(new ToolStripMenuItem("Get older version", null, FileHistory));
                }

                return(mItems.ToArray());
            }

            return(new ToolStripItem[0]);
        }
Example #17
0
    // <summary>
    // Determines whether the menu item can be shown for the selected item.
    // </summary>
    // <returns>
    //   <c>true</c> if item can be shown for the selected item for this instance.;
    // otherwise, <c>false</c>.
    // </returns>
    protected override bool CanShowMenu()
    {
        //  We can show the item only for a single selection.
        //  Make it only show for J, K and L mapped drives.
        var MappedDriveCheck = SelectedItemPaths.First().ToString().Substring(0, 1);

        if (SelectedItemPaths.Count() == 1 && (MappedDriveCheck == "J" || MappedDriveCheck == "K" || MappedDriveCheck == "L"))
        // if (SelectedItemPaths.Count() == 1)
        {
            this.UpdateMenu();
            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #18
0
    // <summary>
    // Shows name of selected files.
    // </summary>
    private void ShowItemPermaLink()
    {
        //  Builder for the output
        var builder = new StringBuilder();

        //
        builder.AppendLine(string.Format("{0}", Path.GetFullPath(SelectedItemPaths.First())));
        // make link
        ConvertPathToURL(ref builder);
        //
        GetDocIDURL(ref builder);
        //  Show the ouput.
        Clipboard.SetText(builder.ToString());
        string outputMessage = string.Format("{0}{1}{1}copied to clipboard", builder.ToString(), Environment.NewLine);

        MessageBox.Show(outputMessage);
    }
Example #19
0
 private void ReadOnlyAttributesMethod()
 {
     string[] array = SelectedItemPaths.Cast <string>().ToArray();
     foreach (string item in array)
     {
         FileAttributes attributes = File.GetAttributes(item);
         if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
         {
             attributes = AttributesInfo.RemoveAttribute(attributes, FileAttributes.ReadOnly);
             File.SetAttributes(item, attributes);
         }
         else
         {
             File.SetAttributes(item, File.GetAttributes(item) | FileAttributes.ReadOnly);
         }
     }
 }
Example #20
0
        protected override ContextMenuStrip CreateMenu()
        {
            ToolStripMenuItem ctxMenu = new ToolStripMenuItem {
                Text  = "MyBackup",
                Image = new Bitmap(Properties.Resources.Backup, new Size(16, 16))
            };

            ToolStripMenuItem backup = new ToolStripMenuItem {
                Text = "Backup manually",
            };

            backup.Click += (o, e) => {
                string workDir = SelectedItemPaths.First();
                bool   isGit   = isGitDir(workDir);
                CallBackupTool((isGit ? "git" : "svn") + " manually " + workDir);
            };

            ToolStripMenuItem backupAll = new ToolStripMenuItem {
                Text = "Backup All",
            };

            backupAll.Click += (o, e) => {
                string workDir = SelectedItemPaths.First();
                bool   isGit   = isGitDir(workDir);
                CallBackupTool((isGit ? "git" : "svn") + " all " + workDir);
            };

            ToolStripMenuItem backupModified = new ToolStripMenuItem {
                Text = "Backup modified",
            };

            backupModified.Click += (o, e) => {
                string workDir = SelectedItemPaths.First();
                bool   isGit   = isGitDir(workDir);
                CallBackupTool((isGit ? "git" : "svn") + " modified " + workDir);
            };

            ctxMenu.DropDownItems.Add(backup);
            ctxMenu.DropDownItems.Add(backupModified);
            ctxMenu.DropDownItems.Add(backupAll);

            m_Menu.Items.Clear();
            m_Menu.Items.Add(ctxMenu);

            return(m_Menu);
        }
        /// <summary>
        /// The click event for the Gist File Item.
        /// </summary>
        /// <param name="sender">The ToolStripMenuItem that triggered the event</param>
        /// <param name="e">The event arguments</param>
        protected void DownloadGist(object sender, EventArgs e)
        {
            var item = (ToolStripMenuItem)sender;
            var url  = item.Tag.ToString();

            var fileContents = GetGist(url);

            if (fileContents == null)
            {
                MessageBox.Show("There was an un-expected error while retrieving your file...", "WinGitter", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            string selectedPath;

            if (SelectedItemPaths.Count() > 0)
            {
                selectedPath = SelectedItemPaths.First();
            }
            else
            {
                selectedPath = this.FolderPath;
            }

            FileAttributes attr = File.GetAttributes(selectedPath);

            if (attr.HasFlag(FileAttributes.Directory))
            {
                // DOES FILE ALREADY EXIST?
                var filePath = Path.Combine(selectedPath, item.Text);
                if (File.Exists(filePath))
                {
                    DialogResult dialogResult = MessageBox.Show("Would you like to overwrite the existing file?", "WinGitter", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dialogResult == DialogResult.No)
                    {
                        return;
                    }
                }

                File.WriteAllText(filePath, fileContents);
            }
            else
            {
                MessageBox.Show("Unexpected bahavior...", "WinGitter", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #22
0
        private void UnZipFiles()
        {
            try {
                if (SelectedItemPaths.Count() == 0)
                {
                    return;
                }

                string[] aFilePath         = SelectedItemPaths.First().Split('.');
                string   destinationFolder = string.Join(".", aFilePath.Take(aFilePath.Length - 1));

                var window = new Compressor(destinationFolder, SelectedItemPaths.First());
                window.Show();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message, "ZipMagikLITE: Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Example #23
0
 private void SystemAttributesMethod()
 {
     string[] array = SelectedItemPaths.Cast <string>().ToArray();
     foreach (string item in array)
     {
         FileAttributes attributes = File.GetAttributes(item);
         if ((attributes & FileAttributes.System) == FileAttributes.System)
         {
             attributes = AttributesInfo.RemoveAttribute(attributes, FileAttributes.System);
             File.SetAttributes(item, attributes);
         }
         else
         {
             File.SetAttributes(item, File.GetAttributes(item) | FileAttributes.System);
         }
     }
     StartProcess.StartInfo(AttributesInfo.GetAssembly.AssemblyInformation("directory") + @"\xMenuTools.exe", "-refresh");
 }
        // <summary>
        // Creates the context menu. This can be a single menu item or a tree of them.
        // Here we create the menu based on the type of item
        // </summary>
        // <returns>
        // The context menu for the shell context menu.
        // </returns>
        protected override ContextMenuStrip CreateMenu()
        {
            menu.Items.Clear();
            FileAttributes attr = File.GetAttributes(SelectedItemPaths.First());

            // check if the selected item is a directory
            if (attr.HasFlag(FileAttributes.Directory))
            {
                this.MenuDirectory();
            }
            else
            {
                this.MenuFiles();
            }

            // return the menu item
            return(menu);
        }
Example #25
0
        protected override bool CanShowMenu()
        {
            var client = ServiceClient.CreateServiceClient(this, 8741);

            try
            {
                var result = client.IsManagedPath(SelectedItemPaths.First());

                ((ICommunicationObject)client).Close();

                return(result);
            }
            catch
            {
                ((ICommunicationObject)client).Abort();
                return(false);
            }
        }
Example #26
0
        private void ProcessFiles(EncryptionMode mode)
        {
            try
            {
                string        space = " ";
                StringBuilder sb    = new StringBuilder();
                sb.Append(mode);
                sb.Append(space);

                if (SelectedItemPaths.Count() > 0)
                {
                    foreach (string file in SelectedItemPaths)
                    {
                        sb.Append("\"");
                        sb.Append(file);
                        sb.Append("\"");
                        sb.Append(space);
                    }
                }
                else
                {
                    // if no file selected (user right-click in the foler background), add the folder
                    sb.Append("\"");
                    sb.Append(FolderPath);
                    sb.Append("\"");
                }

                string dllPath     = new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath;
                string appFullPath = Path.GetDirectoryName(dllPath) + APP_EXE;

                ProcessStartInfo startInfo = new ProcessStartInfo
                {
                    FileName        = appFullPath,
                    Arguments       = sb.ToString(),
                    UseShellExecute = false
                };
                Process.Start(startInfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, caption: "PanMi");
            }
        }
Example #27
0
        /// <summary>
        /// Creates the context menu. This can be a single menu item or a tree of them.
        /// Here we create the menu based on the type of item
        /// </summary>
        /// <returns>
        /// The context menu for the shell context menu.
        /// </returns>
        protected override ContextMenuStrip CreateMenu()
        {
            menu.Items.Clear();

            bool is64bit = PEFileReader.GetPEType(SelectedItemPaths.First()) == PEType.X64;

            // check if the selected executable is 64 bit
            if (is64bit)
            {
                this.MenuX64();
            }
            else
            {
                this.MenuX86();
            }

            // return the menu item
            return(menu);
        }
Example #28
0
        protected void DoToggleReadOnly()
        {
            //  Get the attributes.
            var path       = SelectedItemPaths.First();
            var attributes = File.GetAttributes(path);

            //  Toggle the readonly flag.
            if ((attributes & FileAttributes.ReadOnly) != 0)
            {
                attributes &= ~FileAttributes.ReadOnly;
            }
            else
            {
                attributes |= FileAttributes.ReadOnly;
            }

            //  Set the attributes.
            File.SetAttributes(path, attributes);
        }
        protected override bool CanShowMenu()
        {
            try
            {
                _client = ServiceClient.CreateServiceClient(this, 8741);
                if (!_client.IsAlive())
                {
                    return(false);
                }

                var result = _client.IsManagedPath(SelectedItemPaths.First());

                return(result);
            }
            catch
            {
                return(false);
            }
        }
        private void EncryptFile(object sender, EventArgs eventArgs)
        {
            var viewModel = new EncryptDecryptViewModel(this.SelectedItemPaths.First(), EncryptDecryptViewModel.Functionality.Encrypt);

            var view = new EncryptDecryptView()
            {
                DataContext = viewModel
            };

            Window window = new Window
            {
                Title   = $"Encrypt file {SelectedItemPaths.First()}",
                Content = view,
                Height  = view.Height,
                Width   = view.Width
            };

            window.ShowDialog();
        }