Exemple #1
0
        /// <summary>
        /// Reset the <see cref="QueryGroup"/> back to its default state (as is newly instantiated).
        /// </summary>
        public void Reset()
        {
            // Rest all fields
            if (QueryFields?.Any() == true)
            {
                foreach (var field in QueryFields)
                {
                    field.Reset();
                }
            }

            // Rest all groups
            if (QueryGroups?.Any() == true)
            {
                foreach (var group in QueryGroups)
                {
                    group.Reset();
                }
            }

            // Reset the attribute
            m_conjuctionTextAttribute = null;
            m_isFixed = false;

            // Reset the hash code
            m_hashCode = null;
        }
        private void CreateLabel(IPoint point)
        {
            // 创建文本
            if (label == null)
            {
                label = _axRenderControl.ObjectManager.CreateLabel();
            }

            label.Text     = "我创建了文本——TestLabel";
            label.Position = point;

            if (textAttribute == null)
            {
                textAttribute = new TextAttribute();
            }

            textAttribute.TextColor = 0xffffff00;
            textAttribute.TextSize  = 20;
            textAttribute.Underline = true;
            textAttribute.Font      = "楷体";

            if (textSymbol == null)
            {
                textSymbol = new TextSymbol();
            }
            textSymbol.TextAttribute  = textAttribute;
            textSymbol.VerticalOffset = 10;
            textSymbol.DrawLine       = true;
            textSymbol.MarginColor    = 0x8800ffff;

            label.TextSymbol = textSymbol;
            _axRenderControl.Camera.FlyToObject(label.Guid, i3dActionCode.i3dActionFlyTo);
        }
Exemple #3
0
 /// <summary>
 /// Reset the <see cref="QueryGroup"/> back to its default state (as is newly instantiated).
 /// </summary>
 public void Reset()
 {
     ResetQueryFields();
     ResetQueryGroups();
     conjuctionTextAttribute = null;
     isFixed  = false;
     hashCode = null;
 }
Exemple #4
0
        private void LoadTableLabel()
        {
            dynamicTableLabel = this.axRenderControl1.ObjectManager.CreateTableLabel(3, 2, rootId);

            dynamicTableLabel.TitleText = "直升机当前位置";
            dynamicTableLabel.SetRecord(0, 0, "X:");
            dynamicTableLabel.SetRecord(0, 1, line.GetPoint(0).X.ToString());
            dynamicTableLabel.SetRecord(1, 0, "Y:");
            dynamicTableLabel.SetRecord(1, 1, line.GetPoint(0).Y.ToString());
            dynamicTableLabel.SetRecord(2, 0, "Z:");
            dynamicTableLabel.SetRecord(2, 1, line.GetPoint(0).Z.ToString());

            dynamicTableLabel.Position = line.GetPoint(0);

            dynamicTableLabel.BorderColor          = System.Drawing.Color.FromArgb(255, 255, 255, 255);
            dynamicTableLabel.BorderWidth          = 2;
            dynamicTableLabel.TableBackgroundColor = System.Drawing.Color.FromArgb(200, 255, 255, 165);
            dynamicTableLabel.TitleBackgroundColor = System.Drawing.Color.FromArgb(180, 122, 122, 122);

            // 第一列文本样式
            TextAttribute headerTextAttribute = new TextAttribute();

            headerTextAttribute.TextColor              = System.Drawing.Color.FromArgb(120, 127, 64, 0);
            headerTextAttribute.OutlineColor           = System.Drawing.Color.Red;
            headerTextAttribute.Font                   = "细黑";
            headerTextAttribute.Bold                   = true;
            headerTextAttribute.MultilineJustification = gviMultilineJustification.gviMultilineLeft;
            dynamicTableLabel.SetColumnTextAttribute(0, headerTextAttribute);

            // 第二列文本样式
            TextAttribute contentTextAttribute = new TextAttribute();

            contentTextAttribute.TextColor              = System.Drawing.Color.Black;
            contentTextAttribute.OutlineColor           = System.Drawing.Color.FromArgb(125, 255, 127, 64);
            contentTextAttribute.Font                   = "黑体";
            contentTextAttribute.Bold                   = false;
            contentTextAttribute.MultilineJustification = gviMultilineJustification.gviMultilineLeft;
            dynamicTableLabel.SetColumnTextAttribute(1, contentTextAttribute);

            // 标题文本样式
            TextAttribute capitalTextAttribute = new TextAttribute();

            capitalTextAttribute.TextColor              = System.Drawing.Color.White;
            capitalTextAttribute.OutlineColor           = System.Drawing.Color.Gray;
            capitalTextAttribute.Font                   = "华文新魏";
            capitalTextAttribute.TextSize               = 14;
            capitalTextAttribute.MultilineJustification = gviMultilineJustification.gviMultilineCenter;
            capitalTextAttribute.Bold                   = true;
            dynamicTableLabel.TitleTextAttribute        = capitalTextAttribute;

            // 绑定到运动路径
            IMotionable m = dynamicTableLabel as IMotionable;

            position.Set(0, 0, 2);
            m.Bind2(dynamicObject, position, 0, 0, 0);
        }
Exemple #5
0
        void AddOffsetCopy(TextAttribute attr, int startOffset, int endOffset)
        {
            var copy = attr.Clone();

            copy.StartIndex = startOffset + attr.StartIndex;
            var endIndex = Math.Min(endOffset, startOffset + (attr.StartIndex + attr.Count));

            copy.Count = endIndex - copy.StartIndex;
            list.Add(copy);
        }
Exemple #6
0
 /// <summary>
 /// Gets the value of the <see cref="TextAttribute.Text"/> thas was implemented on the ordering direction.
 /// </summary>
 /// <returns>The string containing the text value of the ordering direction.</returns>
 public string GetOrderText()
 {
     if (orderTextAttribute == null)
     {
         orderTextAttribute = typeof(Order)
                              .GetMembers()
                              .First(member => string.Equals(member.Name, Order.ToString(), StringComparison.OrdinalIgnoreCase))
                              .GetCustomAttribute <TextAttribute>();
     }
     return(orderTextAttribute.Text);
 }
Exemple #7
0
 /// <summary>
 /// Gets the text value of <see cref="TextAttribute"/> implemented at the <see cref="Conjunction"/> property value of this instance.
 /// </summary>
 /// <returns>A string instance containing the value of the <see cref="TextAttribute"/> text property.</returns>
 public string GetConjunctionText()
 {
     if (m_conjuctionTextAttribute == null)
     {
         m_conjuctionTextAttribute = typeof(Conjunction)
                                     .GetMembers()
                                     .First(member => member.Name.ToLower() == Conjunction.ToString().ToLower())
                                     .GetCustomAttribute <TextAttribute>();
     }
     return(m_conjuctionTextAttribute.Text);
 }
Exemple #8
0
 /// <summary>
 /// Gets the value of the <see cref="TextAttribute.Text"/> thas was implemented on the ordering direction.
 /// </summary>
 /// <returns>The string containing the text value of the ordering direction.</returns>
 public string GetOrderText()
 {
     if (m_orderTextAttribute == null)
     {
         m_orderTextAttribute = typeof(Order)
                                .GetMembers()
                                .First(member => member.Name.ToLower() == Order.ToString().ToLower())
                                .GetCustomAttribute <TextAttribute>();
     }
     return(m_orderTextAttribute.Text);
 }
Exemple #9
0
 /// <summary>
 /// Gets the text value of <see cref="TextAttribute"/> implemented at the <see cref="Operation"/> property value of this instance.
 /// </summary>
 /// <returns>A string instance containing the value of the <see cref="TextAttribute"/> text property.</returns>
 public string GetOperationText()
 {
     if (m_operationTextAttribute == null)
     {
         m_operationTextAttribute = typeof(Operation)
                                    .GetMembers()
                                    .First(member => string.Equals(member.Name, Operation.ToString(), StringComparison.OrdinalIgnoreCase))
                                    .GetCustomAttribute <TextAttribute>();
     }
     return(m_operationTextAttribute.Text);
 }
Exemple #10
0
 public void AddAttribute(TextAttribute attribute)
 {
     if (attributes == null)
     {
         attributes = new List <TextAttribute>();
     }
     attributes.Add(attribute);
     if (formattedText != null)
     {
         ApplyAttribute(attribute);
     }
 }
Exemple #11
0
        public void AddAttribute(TextIndexer indexer, TextAttribute attr)
        {
            var start = (uint)indexer.IndexToByteIndex(attr.StartIndex);
            var end   = (uint)indexer.IndexToByteIndex(attr.StartIndex + attr.Count);

            if (attr is BackgroundTextAttribute)
            {
                var xa = (BackgroundTextAttribute)attr;
                AddBackgroundAttribute(xa.Color.ToGtkValue(), start, end);
            }
            else if (attr is ColorTextAttribute)
            {
                var xa = (ColorTextAttribute)attr;
                AddForegroundAttribute(xa.Color.ToGtkValue(), start, end);
            }
            else if (attr is FontWeightTextAttribute)
            {
                var xa = (FontWeightTextAttribute)attr;
                AddWeightAttribute((Pango.Weight)(int) xa.Weight, start, end);
            }
            else if (attr is FontSizeTextAttribute)
            {
                var xa = (FontSizeTextAttribute)attr;
                AddFontSizeAttribute((int)(xa.Size * PangoScale), start, end);
            }
            else if (attr is FontStyleTextAttribute)
            {
                var xa = (FontStyleTextAttribute)attr;
                AddStyleAttribute((Pango.Style)(int) xa.Style, start, end);
            }
            else if (attr is UnderlineTextAttribute)
            {
                var xa = (UnderlineTextAttribute)attr;
                AddUnderlineAttribute(xa.Underline ? Pango.Underline.Single : Pango.Underline.None, start, end);
            }
            else if (attr is StrikethroughTextAttribute)
            {
                var xa = (StrikethroughTextAttribute)attr;
                AddStrikethroughAttribute(xa.Strikethrough, start, end);
            }
            else if (attr is FontTextAttribute)
            {
                var xa = (FontTextAttribute)attr;
                AddFontAttribute((Pango.FontDescription)Toolkit.GetBackend(xa.Font), start, end);
            }
            else if (attr is LinkTextAttribute)
            {
                // TODO: support "link-color" style prop for TextLayoutBackendHandler and CellRendererText
                AddUnderlineAttribute(Pango.Underline.Single, start, end);
                AddForegroundAttribute(DefaultLinkColor, start, end);
            }
        }
        private void Write(
            ITextAttributes currentAttributes,
            TextAttribute key,
            string defaultValue,
            TextWriter writer)
        {
            currentAttributes.TryGetValue(key, out var value);

            if (!string.Equals(value, defaultValue))
            {
                WriteAttribute(writer, key.ToString(), value);
            }
        }
Exemple #13
0
        void ApplyAttribute(TextAttribute attribute)
        {
            if (attribute is FontStyleTextAttribute)
            {
                var xa = (FontStyleTextAttribute)attribute;
                FormattedText.SetFontStyle(xa.Style.ToWpfFontStyle(), xa.StartIndex, xa.Count);
            }
            else if (attribute is FontWeightTextAttribute)
            {
                var xa = (FontWeightTextAttribute)attribute;
                FormattedText.SetFontWeight(xa.Weight.ToWpfFontWeight(), xa.StartIndex, xa.Count);
            }
            else if (attribute is ColorTextAttribute)
            {
                var xa = (ColorTextAttribute)attribute;
                if (xa.StartIndex < FormattedText.Text.Length)
                {
                    FormattedText.SetForegroundBrush(new SolidColorBrush(xa.Color.ToWpfColor()), xa.StartIndex, Math.Min(xa.Count, FormattedText.Text.Length - xa.StartIndex));
                }
            }
            else if (attribute is StrikethroughTextAttribute)
            {
                var xa  = (StrikethroughTextAttribute)attribute;
                var dec = new TextDecoration(TextDecorationLocation.Strikethrough, null, 0, TextDecorationUnit.FontRecommended, TextDecorationUnit.FontRecommended);
                TextDecorationCollection col = new TextDecorationCollection();
                col.Add(dec);
                FormattedText.SetTextDecorations(col, xa.StartIndex, xa.Count);
            }
            else if (attribute is UnderlineTextAttribute)
            {
                var xa  = (UnderlineTextAttribute)attribute;
                var dec = new TextDecoration(TextDecorationLocation.Underline, null, 0, TextDecorationUnit.FontRecommended, TextDecorationUnit.FontRecommended);
                TextDecorationCollection col = new TextDecorationCollection();
                col.Add(dec);
                FormattedText.SetTextDecorations(col, xa.StartIndex, xa.Count);
            }
            else if (attribute is BackgroundTextAttribute)
            {
                // https://stackoverflow.com/questions/37381723/how-to-set-formattedtext-background-color-in-c-sharp
                // No, you cannot.
                // As is the case for anything you draw into a DrawingContext,
                // the properties of the object control only the object itself,
                // i.e. what's actually drawn for that object, not what's
                // behind it or around it.
                // Drawing a rectangle behind the text is the most obvious workaround,
                // and would be entirely appropriate when using the object in a DrawingContext.

                backgroundTextAttributes.Add((BackgroundTextAttribute)attribute);
            }
        }
 public static void SetEnumAttribute <T>(
     this Dictionary <TextAttribute, string> attributes,
     TextAttribute type,
     T value,
     T defaultValue) where T : struct
 {
     if (Equals(value, defaultValue))
     {
         attributes.RemoveAttribute(type);
     }
     else
     {
         attributes.SetAttribute(type, value.ToString());
     }
 }
 public static void SetBoolAttribute(
     this Dictionary <TextAttribute, string> attributes,
     TextAttribute type,
     bool value,
     bool defaultValue = false)
 {
     if (value == defaultValue)
     {
         attributes.RemoveAttribute(type);
     }
     else
     {
         attributes.SetAttribute(type, value.ToString());
     }
 }
Exemple #16
0
        public TextAreaControl(TextAttribute attribute)
        {
            InitializeComponent();
            Label.Content  = attribute.Label;
            Prefix.Content = attribute.Prefix;
            Suffix.Content = attribute.Suffix;
            Binding binding = new Binding();

            binding.Path   = new PropertyPath("Value");
            binding.Source = attribute;
            TextBox.SetBinding(TextBox.TextProperty, binding);
            this.SetValue(Grid.RowProperty, attribute.Row);
            this.SetValue(Grid.ColumnProperty, attribute.Column);
            this.SetValue(Grid.ColumnSpanProperty, attribute.ColumnSpan);
        }
        public static string GetAttribute(
            this ITextAttributes attributes,
            TextAttribute type,
            string defaultValue = null)
        {
            if (attributes != null)
            {
                if (attributes.TryGetValue(type, out var value))
                {
                    return(value);
                }
            }

            return(defaultValue);
        }
 public static void SetIntAttribute(
     this Dictionary <TextAttribute, string> attributes,
     TextAttribute type,
     int value,
     int defaultValue)
 {
     if (value == defaultValue)
     {
         attributes.RemoveAttribute(type);
     }
     else
     {
         attributes.SetAttribute(type, value.ToString(CultureInfo.InvariantCulture));
     }
 }
        public void SetValue_SetsStringAttribute()
        {
            NewElement element = InitializeEmptyNewElement();
            int        id      = 15;
            var        att     = new TextAttribute()
            {
                Id = id
            };

            element.TextAttributes.Add(att);
            string value = "test string";

            element.SetValue(id, value);

            Assert.Equal(value, att.Value);
        }
        public static bool GetBoolAttribute(
            this ITextAttributes attributes,
            TextAttribute type,
            bool defaultValue = false)
        {
            var value = attributes.GetAttribute(type);

            if (value != null)
            {
                if (bool.TryParse(value, out var boolValue))
                {
                    return(boolValue);
                }
            }

            return(defaultValue);
        }
        public void AddAttribute(TextIndexer indexer, TextAttribute attr)
        {
            var start = (uint)indexer.IndexToByteIndex(attr.StartIndex);
            var end   = (uint)indexer.IndexToByteIndex(attr.StartIndex + attr.Count);

            if (attr is BackgroundTextAttribute)
            {
                var xa = (BackgroundTextAttribute)attr;
                AddBackgroundAttribute(xa.Color.ToGtkValue(), start, end);
            }
            else if (attr is ColorTextAttribute)
            {
                var xa = (ColorTextAttribute)attr;
                AddForegroundAttribute(xa.Color.ToGtkValue(), start, end);
            }
            else if (attr is FontWeightTextAttribute)
            {
                var xa = (FontWeightTextAttribute)attr;
                AddWeightAttribute((Pango.Weight)(int) xa.Weight, start, end);
            }
            else if (attr is FontStyleTextAttribute)
            {
                var xa = (FontStyleTextAttribute)attr;
                AddStyleAttribute((Pango.Style)(int) xa.Style, start, end);
            }
            else if (attr is UnderlineTextAttribute)
            {
                var xa = (UnderlineTextAttribute)attr;
                AddUnderlineAttribute(xa.Underline ? Pango.Underline.Single : Pango.Underline.None, start, end);
            }
            else if (attr is StrikethroughTextAttribute)
            {
                var xa = (StrikethroughTextAttribute)attr;
                AddStrikethroughAttribute(xa.Strikethrough, start, end);
            }
            else if (attr is FontTextAttribute)
            {
                var xa = (FontTextAttribute)attr;
                AddFontAttribute((Pango.FontDescription)Toolkit.GetBackend(xa.Font), start, end);
            }
            else if (attr is LinkTextAttribute)
            {
                AddUnderlineAttribute(Pango.Underline.Single, start, end);
                AddForegroundAttribute(Colors.Blue.ToGtkValue(), start, end);
            }
        }
        public static void SetFloatAttribute(
            this Dictionary <TextAttribute, string> attributes,
            TextAttribute type,
            float value,
            float defaultValue)
        {
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
            if (value == defaultValue)
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
            {
                attributes.RemoveAttribute(type);
            }
            else
            {
                attributes.SetAttribute(type, value.ToString(CultureInfo.InvariantCulture));
            }
        }
        public static T GetEnumAttribute <T>(
            this ITextAttributes attributes,
            TextAttribute type,
            T defaultValue) where T : struct
        {
            var value = attributes.GetAttribute(type);

            if (value != null)
            {
                if (Enum.TryParse(value, out T enumValue))
                {
                    return(enumValue);
                }
            }

            return(defaultValue);
        }
        public static float GetFloatAttribute(
            this ITextAttributes attributes,
            TextAttribute type,
            float defaultValue)
        {
            var value = attributes.GetAttribute(type);

            if (value != null)
            {
                if (float.TryParse(value, out var floatValue))
                {
                    return(floatValue);
                }
            }

            return(defaultValue);
        }
        public static int GetIntAttribute(
            this ITextAttributes attributes,
            TextAttribute type,
            int defaultValue)
        {
            var value = attributes.GetAttribute(type);

            if (value != null)
            {
                if (int.TryParse(value, out var intValue))
                {
                    return(intValue);
                }
            }

            return(defaultValue);
        }
 public static void SetAttribute(
     this Dictionary <TextAttribute, string> attributes,
     TextAttribute type,
     string value)
 {
     if (attributes != null)
     {
         if (value == null)
         {
             attributes.Remove(type);
         }
         else
         {
             attributes[type] = value;
         }
     }
 }
Exemple #27
0
        public static ITableLabel CreateTableLabel2(int rowcount)
        {
            AxRenderControl _3DControl = DF3DApplication.Application.Current3DMapControl;

            if (_3DControl != null)
            {
                ITableLabel tableLabel = _3DControl.ObjectManager.CreateTableLabel(rowcount, 2, _3DControl.ProjectTree.RootID);
                tableLabel.BorderColor          = 0xcc068043;   // 表的边框颜色
                tableLabel.BorderWidth          = 2;            // 表的边框的宽度
                tableLabel.TableBackgroundColor = 0xccffffff;   // 表的背景色
                tableLabel.TitleBackgroundColor = 0xcc3366cc;   // 标题背景色

                // 第一列文本样式
                TextAttribute headerTextAttribute = new TextAttribute();
                headerTextAttribute.TextColor              = 0xff3366cc;
                headerTextAttribute.OutlineColor           = 0xff3366cc;
                headerTextAttribute.Font                   = "仿宋";
                headerTextAttribute.TextSize               = 11;
                headerTextAttribute.Bold                   = false;
                headerTextAttribute.MultilineJustification = gviMultilineJustification.gviMultilineLeft;
                tableLabel.SetColumnTextAttribute(0, headerTextAttribute);

                // 第二列文本样式
                TextAttribute contentTextAttribute = new TextAttribute();
                contentTextAttribute.TextColor              = 0xff000000;
                contentTextAttribute.OutlineColor           = 0xff000000;
                contentTextAttribute.Font                   = "仿宋";
                contentTextAttribute.TextSize               = 11;
                contentTextAttribute.Bold                   = false;
                contentTextAttribute.MultilineJustification = gviMultilineJustification.gviMultilineLeft;
                tableLabel.SetColumnTextAttribute(1, contentTextAttribute);

                // 标题文本样式
                TextAttribute capitalTextAttribute = new TextAttribute();
                capitalTextAttribute.TextColor              = 0xffffffff;
                capitalTextAttribute.OutlineColor           = 0xffffffff;
                capitalTextAttribute.Font                   = "宋体";
                capitalTextAttribute.TextSize               = 11;
                capitalTextAttribute.MultilineJustification = gviMultilineJustification.gviMultilineCenter;
                capitalTextAttribute.Bold                   = false;
                tableLabel.TitleTextAttribute               = capitalTextAttribute;
                return(tableLabel);
            }
            return(null);
        }
Exemple #28
0
 private static HelpLine FixLine(HelpLine line)
 {
     TextAttribute[] attributes = new TextAttribute[line.Length];
     for (int i = 0; i < line.Length; i++)
     {
         if (line.Text[i] == '►' &&
             line.Attributes[i].Link != null &&
             (i == line.Length - 1 || line.Attributes[i + 1].Link == null))
         {
             attributes[i] = new TextAttribute(line.Attributes[i].Style, null);
         }
         else
         {
             attributes[i] = line.Attributes[i];
         }
     }
     return(new HelpLine(line.Text, attributes));
 }
Exemple #29
0
        private void SendCurrentStatus()
        {
            _logger.Info("Start sending current status to the central service.");

            var currentStatusMessage = new StatusMessage
            {
                ServiceName       = _serviceName,
                Action            = TextAttribute.GetValueFromEnum(_currentActions.Peek()),
                FakeSettingsValue = _fakeSettingsValue
            };

            try
            {
                _centerQueueClient.Send(currentStatusMessage);
                _logger.Info("The current status was successfully sent to the cental service.");
            }
            catch (Exception exc)
            {
                _logger.Error("The current status was not sent to the central service.", exc);
            }
        }
        /// <summary>
        /// Increment the specified integer counter.
        /// </summary>
        /// <param name="fieldType">Type of the field.</param>
        /// <param name="offset">The offset (bit or ordinal).</param>
        /// <param name="increment">The value to increment.</param>
        /// <param name="offsetIsOrdinal">if set to <c>true</c>, offset is ordinal, so offset=N means the N-th counter of the fieldType size.
        /// If set to <c>false</c>, offset is the bit position, so offset=N means the N-th bit</param>
        /// <param name="overflowType">Overflow handling.</param>
        /// <returns>The previous value.</returns>
        public T BitfieldIncrementBy <T>(BitfieldType fieldType, long offset, T increment, bool offsetIsOrdinal = false, OverflowType overflowType = OverflowType.Wrap)
            where T : struct, IComparable, IComparable <T>, IConvertible, IEquatable <T>, IFormattable
        {
            var db   = GetRedisDb();
            var args = new List <RedisValue>
            {
                "overflow",
                TextAttribute.GetEnumText(overflowType),
                "incrby",
                fieldType.ToString(),
                (offsetIsOrdinal ? "#" : "") + offset,
                Math.Round((decimal)Convert.ChangeType(increment, typeof(decimal)), 0).ToString(CultureInfo.InvariantCulture)
            };
            var results = (RedisResult[])db.ScriptEvaluate(LuaScriptResource.Bitfield, new RedisKey[] { RedisKey }, args.ToArray());

            if (results[0].IsNull)
            {
                throw new OverflowException("The value would overflow the type " + fieldType);
            }
            return((T)Convert.ChangeType((double)results[0], typeof(T)));
        }