Exemplo n.º 1
0
        private void CustomUploaderSyntaxHighlight(RichTextBox rtb)
        {
            string text = rtb.Text;

            if (!string.IsNullOrEmpty(text))
            {
                int start  = rtb.SelectionStart;
                int length = rtb.SelectionLength;
                rtb.BeginUpdate();

                rtb.SelectionStart  = 0;
                rtb.SelectionLength = rtb.TextLength;
                rtb.SelectionColor  = rtb.ForeColor;

                CustomUploaderSyntaxParser parser = new CustomUploaderSyntaxParser();

                for (int i = 0; i < text.Length; i++)
                {
                    char c = text[i];

                    if (c == parser.SyntaxStart || c == parser.SyntaxEnd || c == parser.SyntaxParameterStart ||
                        c == parser.SyntaxParameterDelimiter || c == parser.SyntaxEscape)
                    {
                        rtb.SelectionStart  = i;
                        rtb.SelectionLength = 1;
                        rtb.SelectionColor  = Color.Lime;
                    }
                }

                rtb.SelectionStart  = start;
                rtb.SelectionLength = length;
                rtb.EndUpdate();
            }
        }
Exemplo n.º 2
0
        public override string Call(CustomUploaderSyntaxParser parser, string[] parameters)
        {
            string title        = "ShareX - Prompt";
            string defaultValue = "";

            if (parameters.Length > 0)
            {
                title = parameters[0];

                if (parameters.Length > 1)
                {
                    defaultValue = parameters[1];
                }
            }

            using (InputBox inputBox = new InputBox(title, defaultValue))
            {
                if (inputBox.ShowDialog() == DialogResult.OK)
                {
                    return(inputBox.InputText);
                }
            }

            return(defaultValue);
        }
Exemplo n.º 3
0
        public override string Call(CustomUploaderSyntaxParser parser, string[] parameters)
        {
            if (parser.URLEncode)
            {
                return(URLHelpers.URLEncode(parser.FileName));
            }

            return(parser.FileName);
        }
Exemplo n.º 4
0
        public override string Call(CustomUploaderSyntaxParser parser, string[] parameters)
        {
            if (parameters.Length > 0)
            {
                return(RandomFast.Pick(parameters));
            }

            return(null);
        }
Exemplo n.º 5
0
        public string GetHttpHomePath()
        {
            string homePath = HttpHomePath.Replace("%host", Host);

            CustomUploaderSyntaxParser parser = new CustomUploaderSyntaxParser();

            parser.UseNameParser  = true;
            parser.NameParserType = NameParserType.URL;
            return(parser.Parse(homePath));
        }
Exemplo n.º 6
0
        public override string Call(CustomUploaderSyntaxParser parser, string[] parameters)
        {
            string text = parameters[0];

            if (!string.IsNullOrEmpty(text))
            {
                return(TranslatorHelper.TextToBase64(text));
            }

            return(null);
        }
Exemplo n.º 7
0
        public override string Call(CustomUploaderSyntaxParser parser, string[] parameters)
        {
            string[] values = parameters.Where(x => !string.IsNullOrEmpty(x)).ToArray();

            if (values.Length > 0)
            {
                using (ParserSelectForm form = new ParserSelectForm(values))
                {
                    form.ShowDialog();
                    return(form.SelectedText);
                }
            }

            return(null);
        }
Exemplo n.º 8
0
        public override string Call(CustomUploaderSyntaxParser parser, string[] parameters)
        {
            // https://goessner.net/articles/JsonPath/
            string jsonPath = parameters[0];

            if (!string.IsNullOrEmpty(jsonPath))
            {
                if (!jsonPath.StartsWith("$."))
                {
                    jsonPath = "$." + jsonPath;
                }

                return((string)JToken.Parse(parser.ResponseInfo.ResponseText).SelectToken(jsonPath));
            }

            return(null);
        }
Exemplo n.º 9
0
        public override string Call(CustomUploaderSyntaxParser parser, string[] parameters)
        {
            // https://www.w3schools.com/xml/xpath_syntax.asp
            string xpath = parameters[0];

            if (!string.IsNullOrEmpty(xpath))
            {
                using (StringReader sr = new StringReader(parser.ResponseInfo.ResponseText))
                {
                    XPathDocument  doc  = new XPathDocument(sr);
                    XPathNavigator nav  = doc.CreateNavigator();
                    XPathNavigator node = nav.SelectSingleNode(xpath);

                    if (node != null)
                    {
                        return(node.Value);
                    }
                }
            }

            return(null);
        }
Exemplo n.º 10
0
        public override string Call(CustomUploaderSyntaxParser parser, string[] parameters)
        {
            if (parameters.Length > 0)
            {
                string pattern = parameters[0];

                if (!string.IsNullOrEmpty(pattern))
                {
                    Match match = Regex.Match(parser.ResponseInfo.ResponseText, pattern);

                    if (match.Success)
                    {
                        if (parameters.Length > 1)
                        {
                            string group = parameters[1];

                            if (!string.IsNullOrEmpty(group))
                            {
                                if (int.TryParse(group, out int groupNumber))
                                {
                                    return(match.Groups[groupNumber].Value);
                                }
                                else
                                {
                                    return(match.Groups[group].Value);
                                }
                            }
                        }

                        return(match.Value);
                    }
                }
            }

            return(null);
        }