/// <summary>
 /// Creates a new PathConversionEventArgs class.
 /// </summary>
 /// <param name="mode">The conversion mode.</param>
 /// <param name="path">The initial values for DisplayPath and EditPath.</param>
 /// <param name="root">The root object.</param>
 /// <param name="routedEvent"></param>
 public PathConversionEventArgs(ConversionMode mode, string path, object root, RoutedEvent routedEvent)
     : base(routedEvent)
 {
     Mode = mode;
     DisplayPath = EditPath = path;
     Root = root;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new PathConversionEventArgs class.
 /// </summary>
 /// <param name="mode">The conversion mode.</param>
 /// <param name="path">The initial values for DisplayPath and EditPath.</param>
 /// <param name="root">The root object.</param>
 /// <param name="routedEvent"></param>
 public PathConversionEventArgs(ConversionMode mode, string path, object root, RoutedEvent routedEvent)
     : base(routedEvent)
 {
     Mode        = mode;
     DisplayPath = EditPath = path;
     Root        = root;
 }
Exemplo n.º 3
0
        protected override void Execute(CodeActivityContext context)
        {
            var h = WindowHandle.Get(context);

            if (h == null)
            {
                throw new ArgumentException(Resource.WindowHandleArgumentValidationError);
            }
            int state = 0;
            int mask  = 0;

            if (KeyboardOpenClose.Expression != null)
            {
                if (ConversionMode.Expression != null)
                {
                    throw new ArgumentException(Resource.SetStateInputArgumentValidationError);
                }
                state |= (KeyboardOpenClose.Get(context) ? 1 : 0) << 15;
                mask  |= Bridge.OPENCLOSE;
            }
            else if (ConversionMode.Expression != null)
            {
                state |= (ConversionMode.Get(context) & 0x7fff) << 0;
                mask  |= Bridge.CONVERSION;
            }
            var value = Bridge.SetState(Bridge.ToWin32Handle(h), state, mask);

            PreviousKeyboardOpenClose.Set(context, ((value >> 15) & 1) == 1);
            PreviousConversionMode.Set(context, (value >> 0) & 0x7fff);
        }
Exemplo n.º 4
0
 protected OutputDevice(Job job, ConversionMode conversionMode, IFile file, IOsHelper osHelper, ICommandLineUtil commandLineUtil)
 {
     Job              = job;
     ConversionMode   = conversionMode;
     FileWrap         = file;
     _osHelper        = osHelper;
     _commandLineUtil = commandLineUtil;
 }
        protected override InvocationResult ConversionMissing(Type type, ConversionMode conversionMode)
        {
            if (CanConvertTo(type))
            {
                return new SuccessfulInvocationResult(Convert(type));
            }

            return new FailedInvocationResult();
        }
Exemplo n.º 6
0
        private dynamic ConvertToMsg(IMail email, SaveMailToPdfRequest model)
        {
            ConversionMode noHeaders = model.ConversionMode & ConversionMode.NoHeaders;
            ConversionMode noBody    = model.ConversionMode & ConversionMode.NoBody;
            dynamic        msg       = _outlookInstance.CreateItem(OutlookItemType.MailItem);

            if (noHeaders != ConversionMode.NoHeaders)
            {
                msg.Subject    = email.Subject;
                msg.BodyFormat = MailBodyFormat.FormatHTML;

                msg.SentOnBehalfOfName = email.From[0].Address;
                IEnumerable <MailBox> toMailBoxes = email.To.SelectMany(s => s.GetMailboxes());
                dynamic recipient;
                foreach (MailBox toMailBox in toMailBoxes)
                {
                    recipient      = msg.Recipients.Add(toMailBox.Address);
                    recipient.Type = (int)MailRecipientType.To;
                }

                IEnumerable <MailBox> ccMailBoxes = email.Cc.SelectMany(s => s.GetMailboxes());
                dynamic ccRecipient;
                foreach (MailBox ccMailBox in ccMailBoxes)
                {
                    ccRecipient      = msg.Recipients.Add(ccMailBox.Address);
                    ccRecipient.Type = (int)MailRecipientType.CC;
                }

                IEnumerable <MailBox> bccMailBoxes = email.Bcc.SelectMany(s => s.GetMailboxes());
                dynamic bccRecipient;
                foreach (MailBox bccMailBox in bccMailBoxes)
                {
                    bccRecipient      = msg.Recipients.Add(bccMailBox.Address);
                    bccRecipient.Type = (int)MailRecipientType.BCC;
                }
            }

            if (noBody != ConversionMode.NoBody)
            {
                string bodyHtml = email.GetBodyAsHtml();
                msg.HTMLBody = System.Net.WebUtility.HtmlDecode(bodyHtml);
                string  temporaryItem;
                dynamic attachmentAdded;
                foreach (MimeData visualItem in email.Visuals.Where(x => x.Size < SizeToFilter && !ExtensionToFilterBySize.Contains(Path.GetExtension(x.FileName))))
                {
                    temporaryItem   = visualItem.SaveToTemp();
                    attachmentAdded = msg.Attachments.Add(temporaryItem, MailAttachmentType.Embeddeditem, null, visualItem.FileNameOrDefault());

                    if (_visualAllowedContentTypes.Contains(visualItem.ContentType) && !string.IsNullOrEmpty(visualItem.ContentId))
                    {
                        attachmentAdded.PropertyAccessor.SetProperty(SCHEMANAME_CONTENTID, visualItem.ContentId);
                    }
                }
                ;
            }
            return(msg);
        }
 public FloatSetting(float value, FieldInfo field, string group)
     : base(field, SettingType.Float, group)
 {
     Value = value;
     MinValueAttribute.GetMinValue(field, ref MinValue);
     MaxValueAttribute.GetMaxValue(field, ref MaxValue);
     StepSizeAttribute.GetStepSize(field, ref StepSize);
     ConvertMode     = ConversionModeAttribute.GetConversionMode(field);
     ConversionScale = ConversionScaleAttribute.GetConversionScale(field);
 }
        /// <summary>
        /// データソースを元に、readonly static string ~~のコードを吐き出す。
        /// </summary>
        /// <param name="dataSource"></param>
        /// <returns></returns>
        public string Conversion(string dataSource, ConversionMode mode = ConversionMode.NO_CHANGE)
        {
            if (string.IsNullOrEmpty(dataSource))
            {
                return("");
            }

            dataSource = dataSource.Replace(Environment.NewLine, "\r");

            string[] oneLine = dataSource.Split('\r');

            StringBuilder sb           = new StringBuilder();
            string        variableName = string.Empty;

            // 1行ずつコードに変換していく
            foreach (var item in oneLine)
            {
                // 末尾まで来たらforeachを抜ける
                if (string.IsNullOrEmpty(item))
                {
                    break;
                }

                string[] splited = item.Split('\t');

                switch (mode)
                {
                case ConversionMode.SNAKE:
                    variableName = splited[0].Replace(' ', '_').ToUpper();
                    break;

                case ConversionMode.TITLE_CAMEL:

                    variableName = splited[0].Replace(" ", "").ToTitleCase();
                    break;

                case ConversionMode.PASCAL_CASE:
                    variableName = string.Empty;
                    foreach (var word in splited[0].Split(' '))
                    {
                        variableName += word.ToTitleCase();
                    }

                    break;

                default:
                    variableName = splited[0].Replace(" ", "");
                    break;
                }

                sb.Append($"{PREFIX}{variableName} = \"{splited[1]}\";\r");
            }

            return(sb.ToString());
        }
Exemplo n.º 9
0
        public ModelConverterAttribute(Type conversion, ConversionMode mode)
        {
            Contract.Requires <ArgumentNullException>(conversion != null);

            if (mode != ConversionMode.List && mode != ConversionMode.Object)
            {
                throw new NotSupportedException("mode");
            }
            this.Mode       = mode;
            this.Conversion = conversion;
        }
Exemplo n.º 10
0
        public MathSpook()
        {
            InitializeComponent();

            sendQueued      = false;
            sendTicksWaited = 0;

            mode = ConversionMode.LaTeX;

            webView.EnsureCoreWebView2Async();
        }
Exemplo n.º 11
0
        public bool ConvertToPdf(string sourcePath, string destinationPath, ConversionMode conversionMode = ConversionMode.Default)
        {
            string          extension = Path.GetExtension(sourcePath);
            IToPdfConverter converter = GetConverter(extension);

            if (converter == null)
            {
                throw new Exception(string.Concat("Converter not found for file type ", extension));
            }
            return(converter.Convert(sourcePath, destinationPath, conversionMode));
        }
Exemplo n.º 12
0
        public static ushort StartStatusConversion(ConversionMode mode, int channelIndex)
        {
            Contract.Requires(mode, "mode").ToBeDefinedEnumValue();
            Contract.Requires(channelIndex, "channelIndex").ToBeInRange(x => 0 <= x && x <= 4);

            var commandId = 0x0468;

            commandId |= (int)mode << 7;
            commandId |= channelIndex;

            return((ushort)commandId);
        }
Exemplo n.º 13
0
        public static ushort StartStatusSelfTest(ConversionMode conversionMode, SelfTestMode selfTestMode)
        {
            Contract.Requires(conversionMode, "conversionMode").ToBeDefinedEnumValue();
            Contract.Requires(selfTestMode, "selfTestMode").ToBeDefinedEnumValue();

            var commandId = 0x040F;

            commandId |= (int)conversionMode << 7;
            commandId |= (int)selfTestMode << 5;

            return((ushort)commandId);
        }
Exemplo n.º 14
0
        public void TestMethod1()
        {
            var logic = new MessageListConversion();

            string str = "";

            ConversionMode mode = ConversionMode.SNAKE;

            string result = logic.Conversion(str, mode);

            Assert.AreEqual("", result);
        }
Exemplo n.º 15
0
        private void DoConversion(Job job, ConversionMode conversionMode)
        {
            var ghostScript = GetGhostscript();

            NumberOfPages = job.NumberOfPages;

            try
            {
                ghostScript.Output += Ghostscript_Output;
                job.OutputFiles.Clear();

                _logger.Debug("Starting Ghostscript Job");

                var device = GetOutputDevice(job, conversionMode);

                _logger.Trace("Output format is: {0}", job.Profile.OutputFormat);

                ghostScript.Output += Ghostscript_Logging;
                var success = ghostScript.Run(device, job.JobTempFolder);
                ghostScript.Output -= Ghostscript_Logging;

                _logger.Trace("Finished Ghostscript execution");

                if (!success)
                {
                    var errorMessage = ExtractGhostscriptErrors(ConverterOutput);
                    _logger.Error("Ghostscript execution failed: " + errorMessage);
                    if (errorMessage.Contains("Redistilling encrypted PDF is not permitted"))
                    {
                        throw new ProcessingException("Ghostscript execution failed: " + errorMessage, ErrorCode.Conversion_Ghostscript_PasswordProtectedPDFError);
                    }

                    throw new ProcessingException("Ghostscript execution failed: " + errorMessage, ErrorCode.Conversion_GhostscriptError);
                }

                _logger.Trace("Ghostscript Job was successful");
            }
            catch (ProcessingException ex)
            {
                _logger.Error("There was a Ghostscript error while converting the Job {0}: {1}", job.JobInfo.InfFile, ex);
                throw;
            }
            catch (Exception ex)
            {
                _logger.Error("There was an unexpected error while converting the Job {0}: {1}", job.JobInfo.InfFile, ex);
                throw new ProcessingException("Ghostscript execution failed", ErrorCode.Conversion_GhostscriptError);
            }
            finally
            {
                ghostScript.Output -= Ghostscript_Output;
            }
        }
Exemplo n.º 16
0
 public bool Convert(string source, string destination, ConversionMode conversionMode = ConversionMode.Default)
 {
     using (_service = new OutlookToPdfService(_logger))
     {
         SaveMailToPdfRequest model = new SaveMailToPdfRequest()
         {
             DestinationFilePath = destination,
             ConversionMode      = conversionMode,
             SourceFilePath      = source
         };
         return(_service.SaveTo(model));
     }
 }
Exemplo n.º 17
0
        public static ushort StartCellAuxConversion(ConversionMode mode, bool dischargePermitted)
        {
            Contract.Requires(mode, "mode").ToBeDefinedEnumValue();

            var commandId = 0x046F;

            commandId |= (int)mode << 7;
            if (dischargePermitted)
            {
                commandId |= 1 << 4;
            }

            return((ushort)commandId);
        }
Exemplo n.º 18
0
 public bool Convert(string source, string destination, ConversionMode conversionMode = ConversionMode.Default)
 {
     using (_service = new WordToPdfService(_logger))
     {
         SaveDocumentToPdfRequest model = new SaveDocumentToPdfRequest()
         {
             DestinationFilePath = destination,
             ForcePortrait       = ForcePortrait,
             RedirectFilters     = RedirectFilters,
             SourceFilePath      = source
         };
         return(_service.SaveTo(model));
     }
 }
Exemplo n.º 19
0
 public void Init(bool isPdf, bool isProcessingRequired)
 {
     if (isPdf)
     {
         _firstConversionStepMode = ConversionMode.PdfConversion;
     }
     else if (isProcessingRequired)
     {
         _firstConversionStepMode = ConversionMode.IntermediateConversion;
     }
     else
     {
         _firstConversionStepMode = ConversionMode.ImmediateConversion;
     }
 }
Exemplo n.º 20
0
 public bool Convert(string source, string destination, ConversionMode conversionMode = ConversionMode.Default)
 {
     using (_service = new ExcelToPdfService(_logger))
     {
         SaveWorkbookToPdfRequest model = new SaveWorkbookToPdfRequest()
         {
             DestinationFilePath = destination,
             ForcePortrait       = ForcePortrait,
             FitToPagesTall      = FitToPagesTall,
             FitToPagesWide      = FitToPagesWide,
             SourceFilePath      = source
         };
         return(_service.SaveTo(model));
     }
 }
Exemplo n.º 21
0
        public static ushort StartCellConversion(ConversionMode mode, bool dischargePermitted, int cellIndex)
        {
            Contract.Requires(mode, "mode").ToBeDefinedEnumValue();
            Contract.Requires(cellIndex, "cellIndex").ToBeInRange(x => 0 <= x && x <= 6);

            var commandId = 0x0260;

            commandId |= (int)mode << 7;
            if (dischargePermitted)
            {
                commandId |= 1 << 4;
            }
            commandId |= cellIndex;

            return((ushort)commandId);
        }
        public void Convert(string filePath, ConversionMode mode, string outputFilePath)
        {
            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException(filePath);
            }
            string ds;

            using (var str = new FileInfo(filePath).OpenText()) { ds = str.ReadToEnd(); }
            var dsDocument = this.AvidDSDocumentReader.Read(ds);

            if (string.IsNullOrEmpty(outputFilePath))
            {
                outputFilePath = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath) + ".xlsx");
            }

            this.AvidDSToExcelConverter.Convert(dsDocument, outputFilePath);
        }
Exemplo n.º 23
0
        private OutputDevice GetOutputDevice(Job job, ConversionMode conversionMode)
        {
            OutputDevice device;

            if (conversionMode == ConversionMode.IntermediateConversion)
            {
                return(new PdfIntermediateDevice(job));
            }

            switch (job.Profile.OutputFormat)
            {
            case OutputFormat.PdfA1B:
            case OutputFormat.PdfA2B:
            case OutputFormat.PdfA3B:
            case OutputFormat.PdfX:
            case OutputFormat.Pdf:
                device = new PdfDevice(job, conversionMode);
                break;

            case OutputFormat.Png:
                device = new PngDevice(job, conversionMode);
                break;

            case OutputFormat.Jpeg:
                device = new JpegDevice(job, conversionMode);
                break;

            case OutputFormat.Tif:
                device = new TiffDevice(job, conversionMode);
                break;

            case OutputFormat.Txt:
                device = new TextDevice(job, conversionMode);
                break;

            default:
                throw new Exception("Illegal OutputFormat specified");
            }
            return(device);
        }
Exemplo n.º 24
0
        private string FromNumberConversion()
        {
            ConversionMode kind = this.NumberConversion;

            if (kind == ConversionMode.Full)
            {
                return("full");
            }
            if (kind == ConversionMode.Double)
            {
                return("double");
            }
            if (kind == ConversionMode.Decimal128)
            {
                return("decimal128");
            }
            if (kind == ConversionMode.IntOrFloat)
            {
                return("intorfloat");
            }
            return((kind == ConversionMode.IntOrFloatFromDouble) ?
                   "intorfloatfromdouble" : "full");
        }
Exemplo n.º 25
0
        public string SmartQuotes(string text, ConversionMode mode)
        {
            // Should we educate ``backticks'' -style quotes?
            bool doBackticks = false;

            switch (mode)
            {
                case ConversionMode.LeaveIntact:
                    return text;

                case ConversionMode.EducateOldSchool:
                    doBackticks = true;
                    break;

                default:
                    doBackticks = false;
                    break;
            }

            /*
                Special case to handle quotes at the very end of $text when preceded by
                an HTML tag. Add a space to give the quote education algorithm a bit of
                context, so that it can guess correctly that it's a closing quote:
            */
            bool addExtraSpace = true;

            if (Regex.IsMatch (text, @">['\x22]\z"))
            {
                // Remember, so we can trim the extra space later.
                addExtraSpace = true;
                text += " ";
            }

            ArrayList               tokens = null;
            bool                    inPre = false; // Keep track of when we're inside <pre> or <code> tags
            string                  res = null;

            // This is a cheat, used to get some context
            // for one-character tokens that consist of
            // just a quote char. What we do is remember
            // the last character of the previous text
            // token, to use as context to curl single-
            // character quote tokens correctly.
            string                  prevTokenLastChar = string.Empty;

            // Parse HTML and convert dashes
            tokens = TokenizeHTML (text);

            foreach (Pair token in tokens)
            {
                string value = token.Second.ToString ();

                if (token.First.Equals ("tag"))
                {
                    // Don't mess with quotes inside tags
                    res += value;
                    Match m = Regex.Match (value, tagsToSkip);

                    if (m.Success)
                        inPre = m.Groups[1].Value.Equals ("/") ? false : true;
                }
                else
                {
                    string lastChar = value.Substring (value.Length-1, 1);

                    if (!inPre)
                    {
                        value = ProcessEscapes (value);

                        if (doBackticks)
                            value = EducateBackticks (value);

                        switch (value)
                        {
                            case "'":
                                // Special case: single-character ' token
                                value = (Regex.IsMatch (prevTokenLastChar, @"\S")) ? "&#8217;" : "&#8216;";
                                break;

                            case "\"":
                                // Special case: single-character " token
                                value =  (Regex.IsMatch (prevTokenLastChar, @"\S")) ? "&#8221;" : "&#8220;";
                                break;

                            default:
                                // Normal case:
                                value = EducateQuotes (value);
                                break;
                        }
                    }

                    prevTokenLastChar = lastChar;
                    res += value;
                }
            }

            // Trim trailing space if we added one earlier.
            if (addExtraSpace)
                res = Regex.Replace (res, @" \z", string.Empty);

            return res;
        }
Exemplo n.º 26
0
 public static string MakeParameter(ConversionMode mode)
 {
     return(", ConversionMode::" + mode.ToString());
 }
Exemplo n.º 27
0
 public IComExclusion(ConversionMode mode)
 {
     Mode = mode;
 }
Exemplo n.º 28
0
 public FloatSetting(float value, FieldInfo field, string group)
     : base(field, SettingType.Float, group)
 {
     Value = value;
     MinValueAttribute.GetMinValue(field, ref MinValue);
     MaxValueAttribute.GetMaxValue(field, ref MaxValue);
     StepSizeAttribute.GetStepSize(field, ref StepSize);
     ConvertMode = ConversionModeAttribute.GetConversionMode(field);
     ConversionScale = ConversionScaleAttribute.GetConversionScale(field);
 }
Exemplo n.º 29
0
        // -------------------------------------------------------------------
        public string Transform(string text, ConversionMode mode)
        {
            if (mode == ConversionMode.LeaveIntact)
                return text;

            ArrayList               tokens = null;
            bool                    inPre = false; // Keep track of when we're inside <pre> or <code> tags
            string                  res = null;

            // This is a cheat, used to get some context
            // for one-character tokens that consist of
            // just a quote char. What we do is remember
            // the last character of the previous text
            // token, to use as context to curl single-
            // character quote tokens correctly.
            string                  prevTokenLastChar = string.Empty;

            // Parse HTML and convert dashes
            tokens = TokenizeHTML (text);

            foreach (Pair token in tokens)
            {
                string value = token.Second.ToString ();

                if (token.First.Equals ("tag"))
                {
                    // Don't mess with quotes inside tags
                    res += value;
                    Match m = Regex.Match (value, tagsToSkip);

                    if (m.Success)
                        inPre = m.Groups[1].Value.Equals ("/") ? false : true;
                }
                else
                {
                    string lastChar = value.Substring (value.Length-1, 1);

                    if (!inPre)
                    {
                        value = ProcessEscapes (value);

                        if (mode == ConversionMode.Stupefy)
                        {
                            value = StupefyEntities (value);
                        }
                        else
                        {
                            switch (mode)
                            {
                                case ConversionMode.EducateDefault:             value = EducateDashes (value); break;
                                case ConversionMode.EducateOldSchool:           value = EducateDashesOldSchool (value); break;
                                case ConversionMode.EducateOldSchoolInverted:   value = EducateDashesOldSchoolInverted (value); break;
                            }

                            value = EducateEllipses (value);

                            // Note: backticks need to be processed before quotes.
                            value = EducateBackticks (value);

                            if (mode == ConversionMode.EducateOldSchool)
                                value = EducateSingleBackticks (value);

                            switch (value)
                            {
                                case "'":
                                    // Special case: single-character ' token
                                    value = Regex.IsMatch (prevTokenLastChar, @"\S") ? "&#8217;" : "&#8216;";
                                    break;

                                case "\"":
                                    // Special case: single-character " token
                                    value = Regex.IsMatch (prevTokenLastChar, @"\S") ? "&#8221;" : "&#8220;";
                                    break;

                                default:
                                    // Normal case:
                                    value = EducateQuotes (value);
                                    break;
                            }
                        }
                    }

                    prevTokenLastChar = lastChar;
                    res += value;
                }
            }

            return res;
        }
Exemplo n.º 30
0
 protected virtual InvocationResult ConversionMissing(Type type, ConversionMode conversionMode)
 {
     return new FailedInvocationResult();
 }
Exemplo n.º 31
0
        public string SmartDashes(string text, ConversionMode mode)
        {
            ArrayList               tokens = null;
            bool                    inPre = false; // Keep track of when we're inside <pre> or <code> tags
            string                  res = null;
            ConvertDashesDelegate   cd = null;

            switch (mode)
            {
                case ConversionMode.LeaveIntact:
                    return text;

                case ConversionMode.EducateDefault:
                    // Reference to the method to use for dash education, default to EducateDashes:
                    cd = new ConvertDashesDelegate (EducateDashes);
                    break;

                case ConversionMode.EducateOldSchool:
                    // Use old smart dash shortcuts, "--" for en, "---" for em
                    cd = new ConvertDashesDelegate (EducateDashesOldSchool);
                    break;

                case ConversionMode.EducateOldSchoolInverted:
                    // Inverse of previous, "--" for em, "---" for en
                    cd = new ConvertDashesDelegate (EducateDashesOldSchoolInverted);
                    break;
            }

            // Parse HTML and convert dashes
            tokens = TokenizeHTML (text);

            foreach (Pair token in tokens)
            {
                string value = token.Second.ToString ();

                if (token.First.Equals ("tag"))
                {
                    // Don't mess with quotes inside tags
                    res += value;
                    Match m = Regex.Match (value, tagsToSkip);

                    if (m.Success)
                        inPre = m.Groups[1].Value.Equals ("/") ? false : true;
                }
                else
                {
                    if (!inPre)
                    {
                        value = ProcessEscapes (value);
                        value = cd (value);
                    }
                    res += value;
                }
            }
            return res;
        }
Exemplo n.º 32
0
 public ConversionModeAttribute(ConversionMode mode)
 {
     this.Mode = mode;
 }
Exemplo n.º 33
0
 public TextDevice(Job job, ConversionMode conversionMode, IFile file, IOsHelper osHelper, ICommandLineUtil commandLineUtil) : base(job, conversionMode, file, osHelper, commandLineUtil)
 {
 }
Exemplo n.º 34
0
        public string SmartEllipses(string text, ConversionMode mode)
        {
            if (mode == ConversionMode.LeaveIntact)
                return text;

            ArrayList   tokens = TokenizeHTML (text);
            bool        inPre = false; // Keep track of when we're inside <pre> or <code> tags
            string      res = null;

            foreach (Pair token in tokens)
            {
                string value = token.Second.ToString ();

                if (token.First.Equals ("tag"))
                {
                    // Don't mess with quotes inside tags
                    res += value;
                    Match m = Regex.Match (value, tagsToSkip);

                    if (m.Success)
                        inPre = m.Groups[1].Value.Equals ("/") ? false : true;
                }
                else
                {
                    if (!inPre)
                    {
                        value = ProcessEscapes (value);
                        value = EducateEllipses (value);
                    }
                    res += value;
                }
            }
            return res;
        }
Exemplo n.º 35
0
 private void jSONToolStripMenuItem_Click(object sender, EventArgs e)
 {
     mode = ConversionMode.JSON;
     convert();
 }
Exemplo n.º 36
0
 public ConversionModeAttribute(ConversionMode mode)
 {
     this.Mode = mode;
 }
Exemplo n.º 37
0
        /// <summary>
        /// returns a list of object properties that have been flaged by a specific Attribute
        /// </summary>
        /// <param name="intendedType"></param>
        /// <param name="mode"></param>
        /// <returns></returns>
        public static List <PropertyInfo> GetCommunicationFlaggedProperties(Type intendedType, ConversionMode mode, Type targetType = null)
        {
            if (CachePropertyInfos == null)
            {
                CachePropertyInfos = new Dictionary <string, List <PropertyInfo> >();
            }

            var key = intendedType.ToString() + (targetType == null ? "" : targetType.ToString()) + mode.ToString();

            if (CachePropertyInfos.Keys.Contains(key))
            {
                return(CachePropertyInfos[key]);
            }

            if (targetType == null)
            {
                var result = (from x in intendedType.GetProperties()
                              let y = (from z in x.GetCustomAttributes(typeof(IComExclusion), true) where ((IComExclusion)z).Mode == mode select z).Count()
                                      where y == 0
                                      select x).ToList();

                CachePropertyInfos.Add(key, result);

                return(result);
            }
            else
            {
                var result = (from x in intendedType.GetProperties()
                              join c in targetType.GetProperties() on x.Name equals c.Name
                              let y = (from z in x.GetCustomAttributes(typeof(IComExclusion), true) where ((IComExclusion)z).Mode == mode select z).Count()
                                      let y1 = (from z1 in c.GetCustomAttributes(typeof(IComExclusion), true) where ((IComExclusion)z1).Mode == mode select z1).Count()

                                               where y == 0 && y1 == 0
                                               select x).ToList();

                CachePropertyInfos.Add(key, result);

                return(result);
            }
        }
Exemplo n.º 38
0
 public TextDevice(Job job, ConversionMode conversionMode) : base(job, conversionMode)
 {
 }
Exemplo n.º 39
0
 public static string MakeParameter(ConversionMode mode)
 {
     return ", ConversionMode::" + mode.ToString();
 }
Exemplo n.º 40
0
        public static List <FunScriptAction> Convert(IEnumerable <TimeSpan> timestamps, ConversionMode mode)
        {
            var beats   = timestamps.ToList();
            var actions = new List <FunScriptAction>();

            TimeSpan previous    = TimeSpan.MinValue;
            TimeSpan centerLimit = TimeSpan.MaxValue;

            bool up = true;

            byte positionDown;
            byte positionUp;

            switch (mode)
            {
            case ConversionMode.UpOrDown:
                centerLimit  = TimeSpan.Zero;
                positionDown = 5;
                positionUp   = 95;
                break;

            case ConversionMode.DownFast:
                centerLimit  = TimeSpan.FromMilliseconds(180);
                positionDown = 95;
                positionUp   = 5;
                break;

            case ConversionMode.DownCenter:
                centerLimit  = TimeSpan.FromMilliseconds(2000);
                positionDown = 95;
                positionUp   = 5;
                break;

            case ConversionMode.UpFast:
                centerLimit  = TimeSpan.FromMilliseconds(180);
                positionDown = 5;
                positionUp   = 95;
                break;

            case ConversionMode.UpCenter:
                centerLimit  = TimeSpan.FromMilliseconds(2000);
                positionDown = 5;
                positionUp   = 95;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(mode), mode, null);
            }

            foreach (TimeSpan timestamp in beats)
            {
                switch (mode)
                {
                case ConversionMode.UpOrDown:
                {
                    up ^= true;

                    actions.Add(new FunScriptAction
                        {
                            Position  = up ? positionUp : positionDown,
                            TimeStamp = timestamp
                        });
                    break;
                }

                case ConversionMode.UpCenter:
                case ConversionMode.DownCenter:
                case ConversionMode.UpFast:
                case ConversionMode.DownFast:
                {
                    if (previous != TimeSpan.MinValue)
                    {
                        if (timestamp - previous >= centerLimit.Multiply(2))
                        {
                            actions.Add(new FunScriptAction
                                {
                                    Position  = positionDown,
                                    TimeStamp = previous + centerLimit
                                });

                            actions.Add(new FunScriptAction
                                {
                                    Position  = positionDown,
                                    TimeStamp = timestamp - centerLimit
                                });
                        }
                        else
                        {
                            actions.Add(new FunScriptAction
                                {
                                    Position  = positionDown,
                                    TimeStamp = (previous + timestamp).Divide(2)
                                });
                        }
                    }
                }

                    actions.Add(new FunScriptAction
                    {
                        Position  = positionUp,
                        TimeStamp = timestamp
                    });

                    break;
                }

                previous = timestamp;
            }

            return(actions);
        }
Exemplo n.º 41
0
        protected override InvocationResult ConversionMissing(Type type, ConversionMode conversionMode)
        {
            var value = new ConvertibleStringValue(_element.Value, _valueConverter);

            if (value.CanConvertTo(type))
            {
                return new SuccessfulInvocationResult(value.Convert(type));
            }

            return new FailedInvocationResult();
        }