aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.CodeGeneration/Templates/DpProperty.cshtml
blob: aa0b578647d4696fc1b94f31d9a18d4819e04ec6 (plain)
1
2
3
4
5
6
7
8
        @(Model.GetAttributesString())
        public @(Model.Type) @(Model.Name)
        {
            get { return (@(Model.Type))GetValue(@(Model.Name)Property); }
            set { SetValue(@(Model.Name)Property, value); }
        }
        public static readonly DependencyProperty @(Model.Name)Property =
            DependencyProperty.Register("@(Model.Name)", typeof(@(Model.Type)), typeof(@(Model.OwnerClass)), new PropertyMetadata(@(Model.DefaultValue) @(Model.PropertyChangedCallback != null ? ", " + Model.PropertyChangedCallback : "")));
l.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
using Tango.Scripting.Editors.Document;
using Tango.Scripting.Editors.Editing;

namespace Tango.Scripting.Editors.Intellisense
{
    public abstract class CompletionItem : DependencyObject, ICompletionItem
    {
        public abstract string Text { get; }
        public object Description { get; set; }
        public double Priority { get; set; }
        public abstract CompletionItemPopupControl PopupControl { get; }

        public bool IsSelected
        {
            get { return (bool)GetValue(IsSelectedProperty); }
            set { SetValue(IsSelectedProperty, value); }
        }
        public static readonly DependencyProperty IsSelectedProperty =
            DependencyProperty.Register("IsSelected", typeof(bool), typeof(CompletionItem), new PropertyMetadata(false));

        public virtual void Complete(ScriptEditor editor)
        {
            var word = editor.GetCurrentWord();
            int index = editor.GetCurrentWordStartIndex();
            int max = editor.GetCurrentLine().EndOffset;

            editor.Document.Replace(index, word.Length, GetCode());
        }

        public abstract BitmapSource Image { get; }

        protected static BitmapSource GetImage(String name)
        {
            return new BitmapImage(new Uri($"pack://application:,,,/Tango.Scripting.Editors;component/Images/{name}", UriKind.Absolute));
        }

        protected virtual String GetCode()
        {
            return Text;
        }

        public override string ToString()
        {
            return Text;
        }
    }
}