예제 #1
0
        public void SwitchTo(FormatMode newMode)
        {
            if (m_currentMode == newMode)
            {
                return;
            }

            BaseViewer preViewer = GetCurrentMode();

            if (preViewer != null)
            {
                preViewer.OnLeave();
            }

            m_currentMode = newMode;

            BaseViewer curViewer = GetCurrentMode();

            if (curViewer != null)
            {
                curViewer.OnEnter();
            }

            EditorPrefs.SetInt(TableConst.CurrentMode, (int)(m_currentMode));
        }
예제 #2
0
        private void SwitchFormatMode(FormatMode mode)
        {
            switch (mode)
            {
            case FormatMode.Mini:
                lbHex.Width   = Util.ScaleX(68);
                lbHex.Visible = true;
                lbRgb.Visible = false;
                pnExt.Visible = false;
                Height        = Util.ScaleY(20);
                Width         = Util.ScaleX(88);
                break;

            case FormatMode.Standard:
                lbHex.Width   = Util.ScaleX(68);
                lbRgb.Width   = Util.ScaleX(140);
                lbRgb.Left    = Util.ScaleX(88);
                lbRgb.Top     = 0;
                lbHex.Visible = true;
                lbRgb.Visible = true;
                pnExt.Visible = false;
                Height        = Util.ScaleY(20);
                Width         = Util.ScaleX(228);
                break;

            case FormatMode.Extention:
                // 让两边都留下20宽度,以使显示居中
                lbHex.Width   = Util.ScaleX(140);
                lbRgb.Width   = Util.ScaleX(180);
                lbRgb.Left    = 0;
                lbRgb.Top     = Util.ScaleY(20);
                lbHex.Visible = true;
                lbRgb.Visible = true;
                pnExt.Visible = true;
                Height        = Util.ScaleY(100);
                Width         = Util.ScaleX(180);
                break;

            case FormatMode.Shot:
                lbHex.Visible = false;
                lbRgb.Visible = false;
                pnExt.Visible = false;
                Height        = Util.ScaleY(20);
                Width         = Util.ScaleX(20);
                break;
            }
            currentFormatMode = mode;

            if (settingLoaded)
            {
                Settings.Main.Format = mode;
            }
            // 切换了显示格式后,自动重算预览窗口位置
            if (previewForm.Visible && Settings.Preview.PinPosition != PinPosition.None)
            {
                UpdatePreviewPosition();
            }
        }
예제 #3
0
        public override string Format(ITypeScriptLibrary lib, FormatMode mode = FormatMode.Markdown)
        {
            if (Signature != null)
            {
                return($"({string.Join(", ", Signature.Parameters.Select(p => p.Format(lib, mode)))}) => {Signature.Type.Format(lib, mode)}");
            }

            return(MarkdownBuilder.MarkdownCodeQuote("any"));
        }
예제 #4
0
        public string Format(ITypeScriptLibrary lib, FormatMode mode = FormatMode.Markdown)
        {
            var sb = new StringBuilder();

            foreach (var singature in Signatures)
            {
                sb.AppendLine("▸ " + singature.Format(lib));
            }

            return(sb.ToString());
        }
예제 #5
0
 public void addInfo <K, V>(string key, K value, IDictionary <K, V> dict, FormatMode format, bool extra)
 {
     if (dict.TryGetValue(value, out V v))
     {
         addInfo(key, v, format, extra);
     }
     else
     {
         addInfo(key, String.Format("Unknown ({0})", value), extra);
     }
 }
예제 #6
0
        private void SwitchFormatMode(FormatMode mode)
        {
            switch (mode)
            {
            case FormatMode.Mini:
                trayMenuFormatMini.Checked      = true;
                trayMenuFormatStandard.Checked  = false;
                trayMenuFormatExtention.Checked = false;

                lbHex.Width   = 68;
                lbRgb.Visible = false;
                pnExt.Visible = false;
                Height        = 20;
                Width         = 88;
                break;

            case FormatMode.Standard:
                trayMenuFormatMini.Checked      = false;
                trayMenuFormatStandard.Checked  = true;
                trayMenuFormatExtention.Checked = false;

                lbHex.Width   = 68;
                lbRgb.Width   = 140;
                lbRgb.Left    = 68;
                lbRgb.Top     = 0;
                lbRgb.Visible = true;
                pnExt.Visible = false;
                Height        = 20;
                Width         = 208;
                break;

            case FormatMode.Extention:
                trayMenuFormatMini.Checked      = false;
                trayMenuFormatStandard.Checked  = false;
                trayMenuFormatExtention.Checked = true;

                lbHex.Width   = 180;
                lbRgb.Width   = 180;
                lbRgb.Left    = 0;
                lbRgb.Top     = 20;
                lbRgb.Visible = true;
                pnExt.Visible = true;
                Height        = 100;
                Width         = 180;
                break;
            }
            currentFormatMode = mode;

            if (settingLoaded)
            {
                Settings.Main.Format = mode;
            }
        }
예제 #7
0
        public override string Format(ITypeScriptLibrary lib, FormatMode mode = FormatMode.Markdown)
        {
            var path = lib.FindPathToType(Name);
            var name = path != null?MarkdownBuilder.MarkdownUrl(Name, path) : MarkdownBuilder.MarkdownCodeQuote(Name);

            if (TypeArguments.Any())
            {
                name += "&lt;" + string.Join(",", TypeArguments.Select(t => t.Format(lib, mode))) + "&gt;";
            }

            return(name);
        }
예제 #8
0
        /// <summary>
        /// Formats a specified string replacing placeholders with content
        /// </summary>
        /// <param name="theme"></param>
        /// <param name="content"></param>
        /// <param name="formatMode"></param>
        /// <param name="staticContentLookup"></param>
        /// <param name="themeFolderLookup"></param>
        /// <returns></returns>
        public static string Format(
            string theme
            , string content
            , IStaticContentLookup staticContentLookup
            , IThemeFolderLookup themeFolderLookup
            , FormatMode formatMode)
        {
            if (string.IsNullOrWhiteSpace(content))
            {
                return(content);
            }
            // TODO (Roman): implement URL.RESOLVE to be able to resolve url root folders, not only theme paths...
            string value;

            foreach (Match match in _ContentRegex.Matches(content))
            {
                value = staticContentLookup.GetContent(theme, match.Groups[1].Value);
                if ((formatMode & FormatMode.EscapeSingleQuotes) != 0)
                {
                    value = value.Replace("'", @"\'");
                }
                if ((formatMode & FormatMode.EscapeDoubleQuotes) != 0)
                {
                    value = value.Replace("\"", @"\""");
                }

                content = content.Replace(match.Value, value);
            }
            foreach (Match match in _UrlRegex.Matches(content))
            {
                value = themeFolderLookup.GetAbsoluteThemePath(theme, match.Groups[1].Value);
                if ((formatMode & FormatMode.EscapeSingleQuotes) != 0)
                {
                    value = value.Replace("'", @"\'");
                }
                if ((formatMode & FormatMode.EscapeDoubleQuotes) != 0)
                {
                    value = value.Replace("\"", @"\""");
                }

                content = content.Replace(match.Value, value);
            }

            return(content);
        }
예제 #9
0
        public string Format(ITypeScriptLibrary lib, FormatMode mode)
        {
            var sb = new StringBuilder();

            if (GetSignature != null)
            {
                sb.AppendLine("⇄ " + GetSignature.Format(lib));
                sb.AppendLine();
            }

            if (SetSignature != null)
            {
                sb.AppendLine("⇄ " + SetSignature.Format(lib));
                sb.AppendLine();
            }

            return(sb.ToString());
        }
 public static string Create(FormatMode mode, ObservableCollection <ColorInfo> colorInfos, Range rect = null)
 {
     return(mode switch
     {
         FormatMode.compareStr => CompareStr(colorInfos),
         FormatMode.dmFindStr => DmFindStr(colorInfos, rect),
         FormatMode.ajFindStr => AjFindStr(colorInfos, rect),
         FormatMode.ajCompareStr => AjCompareStr(colorInfos),
         FormatMode.cdFindStr => CdFindStr(colorInfos, rect),
         FormatMode.cdCompareStr => CdCompareStr(colorInfos),
         FormatMode.autojsFindStr => AutojsFindStr(colorInfos, rect),
         FormatMode.ecFindStr => EcFindStr(colorInfos, rect),
         FormatMode.diyFindStr => DiyFindStr(colorInfos, rect),
         FormatMode.diyCompareStr => DiyCompareStr(colorInfos),
         FormatMode.anchorsCompareStr => AnchorsCompareStr(colorInfos),
         FormatMode.anchorsFindStr => AnchorsFindStr(colorInfos, rect),
         FormatMode.anchorsCompareStrTest => AnchorsCompareStrTest(colorInfos),
         FormatMode.anchorsFindStrTest => AnchorsCompareStrTest(colorInfos),
         _ => CompareStr(colorInfos),
     });
예제 #11
0
        public string Format(ITypeScriptLibrary lib, FormatMode mode = FormatMode.Markdown)
        {
            var result = "";

            if (IsRest)
            {
                result += "...";
            }

            result += Name;

            if (IsOptional || DefaultValue != null)
            {
                result += "?";
            }


            result += ": ";
            result += Type.Format(lib, mode);

            return(result);
        }
예제 #12
0
        string FormatTime(int milliseconds, FormatMode mode = FormatMode.Lap, int smallSize = 10)
        {
            bool negative = false;

            if (milliseconds < 0)
            {
                negative     = true;
                milliseconds = -milliseconds;
            }

            int seconds = milliseconds / 1000;

            int m  = seconds / 60;
            int s  = seconds % 60;
            int mm = milliseconds % 1000;

            string prefix = negative? "-" : mode == FormatMode.Delta? "+" : "";

            if (m < 100)
            {
                if (seconds < 100 && mode != FormatMode.Lap)
                {
                    return(string.Format("{0}{1}<size={2}>.{3,3:000}</size>", prefix, seconds, smallSize, mm));
                }
                else
                {
                    return(string.Format("{0}{1}:{2,2:00}<size={3}>.{4,3:000}</size>", prefix, m, s, smallSize, mm));
                }
            }
            else
            {
                int h = m / 60;
                m = m % 60;

                int d = mm / 100;
                return(string.Format("{0}{1}:{2,2:00}:{3,2:00}<size={4}>.{5}</size>", prefix, h, m, s, smallSize, d));
            }
        }
예제 #13
0
 public void addInfo(string key, object value, FormatMode format)
 {
     addInfo(key, value, format, false);
 }
예제 #14
0
 public override string Format(ITypeScriptLibrary lib, FormatMode mode = FormatMode.Markdown)
 {
     return(string.Join(" | ", Types.Select(t => t.Format(lib, mode))));
 }
예제 #15
0
 public string Format(ITypeScriptLibrary lib, FormatMode mode = FormatMode.Markdown)
 {
     return("▸ " + Signature.Format(lib));
 }
예제 #16
0
 public override string Format(ITypeScriptLibrary lib, FormatMode mode = FormatMode.Markdown)
 {
     return(ElementType.Format(lib, mode) + "[]");
 }
예제 #17
0
 public override string Format(ITypeScriptLibrary lib, FormatMode mode = FormatMode.Markdown)
 {
     return(MarkdownBuilder.MarkdownCodeQuote("\"" + Value + "\""));
 }
예제 #18
0
 public virtual string Format(ITypeScriptLibrary lib, FormatMode mode = FormatMode.Markdown)
 {
     return(MarkdownBuilder.MarkdownCodeQuote(Name));
 }
예제 #19
0
        private void SwitchFormatMode(FormatMode mode)
        {
            switch (mode)
            {
            case FormatMode.Mini:
                trayMenuFormatMini.Checked      = true;
                trayMenuFormatStandard.Checked  = false;
                trayMenuFormatExtention.Checked = false;
                trayMenuFormatShot.Checked      = false;

                lbHex.Width   = 68;
                lbHex.Visible = true;
                lbRgb.Visible = false;
                pnExt.Visible = false;
                Height        = 20;
                Width         = 108;
                break;

            case FormatMode.Standard:
                trayMenuFormatMini.Checked      = false;
                trayMenuFormatStandard.Checked  = true;
                trayMenuFormatExtention.Checked = false;
                trayMenuFormatShot.Checked      = false;

                lbHex.Width   = 68;
                lbRgb.Width   = 140;
                lbRgb.Left    = 88;
                lbRgb.Top     = 0;
                lbHex.Visible = true;
                lbRgb.Visible = true;
                pnExt.Visible = false;
                Height        = 20;
                Width         = 228;
                break;

            case FormatMode.Extention:
                trayMenuFormatMini.Checked      = false;
                trayMenuFormatStandard.Checked  = false;
                trayMenuFormatExtention.Checked = true;
                trayMenuFormatShot.Checked      = false;

                // 让两边都留下20宽度,以使显示居中
                lbHex.Width   = 140;
                lbRgb.Width   = 180;
                lbRgb.Left    = 0;
                lbRgb.Top     = 20;
                lbHex.Visible = true;
                lbRgb.Visible = true;
                pnExt.Visible = true;
                Height        = 100;
                Width         = 180;
                break;

            case FormatMode.Shot:
                trayMenuFormatMini.Checked      = false;
                trayMenuFormatStandard.Checked  = false;
                trayMenuFormatExtention.Checked = false;
                trayMenuFormatShot.Checked      = true;

                lbHex.Visible = false;
                lbRgb.Visible = false;
                pnExt.Visible = false;
                Height        = 20;
                Width         = 20;
                break;
            }
            currentFormatMode = mode;

            if (settingLoaded)
            {
                Settings.Main.Format = mode;
            }
            // 切换了显示格式后,自动重算预览窗口位置
            if (previewForm.Visible && Settings.Preview.PinPosition != PinPosition.None)
            {
                UpdatePreviewPosition();
            }
        }
 protected FormattableComponent()
 {
     this.format = "{0}";
     this.mode   = FormatMode.String;
 }
 public virtual IFormattableComponent FormattedAs(string formatString)
 {
     this.mode   = FormatMode.String;
     this.format = string.Concat("{0:", formatString, "}");
     return(this);
 }
 public virtual IFormattableComponent <TProperty> FormatWith(Func <TProperty, string> formatFunc)
 {
     this.mode           = FormatMode.Func;
     this.formatFunction = formatFunc;
     return(this);
 }
예제 #23
0
 public void addInfo <K, V>(string key, K value, IDictionary <K, V> dict, FormatMode format)
 {
     addInfo(key, value, dict, format, false);
 }
예제 #24
0
 public InfoItem(object value, FormatMode formatMode) : this(value, formatMode, false)
 {
 }
예제 #25
0
 public InfoItem(object value, FormatMode formatMode, bool extra)
 {
     this.value      = value;
     this.formatMode = formatMode;
     this.extra      = extra;
 }
예제 #26
0
 public string Format(ITypeScriptLibrary lib, FormatMode mode = FormatMode.Markdown)
 {
     return($"{Name}({string.Join(",", Parameters.Select(p => p.Format(lib, mode)))}): {Type.Format(lib, mode)}");
 }
예제 #27
0
 public void addInfo(string key, object value, FormatMode format, bool extra)
 {
     info.Add(key, new InfoItem(value, format, extra));
 }
예제 #28
0
 public string Format(ITypeScriptLibrary lib, FormatMode mode = FormatMode.Markdown)
 {
     return($"● {Name}:{Type.Format(lib)}{((DefaultValue != null) ? " = " + MarkdownBuilder.MarkdownCodeQuote(DefaultValue) : "")}");
 }
예제 #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EnumDisplayAttribute"/> class.
 /// </summary>
 /// <param name="mode">The formatting mode.</param>
 public EnumDisplayAttribute(FormatMode mode)
 {
     Mode = mode;
 }