private static FrameworkElement ExtractBool(DisplayOption option)
        {
            var ctrl = new CheckBox();

            ctrl.SetBinding(ToggleButton.IsCheckedProperty, new Binding(option.PropertyName));
            return(ctrl);
        }
示例#2
0
文件: Form1.cs 项目: AdamDIOM/NEA
        /*public async void WindowLoop()
         * {
         *  bool run = RunLoop();
         * }
         * async Task<bool> RunLoop()
         * {
         *  while (true)
         *  {
         *
         *  }
         *  return true;
         * }*/
        private void InitialiseTable(/*ref DisplayOption ShowMenu, */ TableLayoutPanel tblLayout)
        {
            /*sets up the table width (window width), height (window heigh - 39),
             * sets it to anchor to all sides so it can be resized, adds 6 rows and 5 columns*/
            tblLayout.Width       = Width;
            tblLayout.Height      = Height - 39;
            tblLayout.Anchor      = (AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom);
            tblLayout.ColumnCount = 5;
            tblLayout.RowCount    = 6;
            //temporary border for testing purposes
            tblLayout.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;

            //sets each column to be 20% of the width of the window
            for (int i = 0; i < tblLayout.ColumnCount; i++)
            {
                tblLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20));
            }
            //sets the first row to be 20% of the window height
            tblLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 20));
            //sets the remaining rows to be 16% of the window height (20% of remaining height)
            for (int i = 1; i < tblLayout.RowCount; i++)
            {
                tblLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 16));
            }

            //TitleScreen(ref ShowMenu, tblLayout);// replaced with delegate
            ShowMenu = new DisplayOption(TitleScreen);
            //ShowMenu(ref ShowMenu, tblLayout);

            Controls.Add(tblLayout);
        }
        private static FrameworkElement ExtractInt(DisplayOption option)
        {
            var ctrl = new IntegerUpDown
            {
                Margin = new Thickness(3),
                HorizontalAlignment = HorizontalAlignment.Left,
                MinWidth            = 50
            };

            ctrl.SetBinding(IntegerUpDown.ValueProperty, new Binding(option.PropertyName));

            int newVal;

            if (option.Minimum != null)
            {
                newVal       = Convert.ToInt32(option.Minimum);
                ctrl.Minimum = newVal;
            }
            if (option.Maximum != null)
            {
                newVal       = Convert.ToInt32(option.Maximum);
                ctrl.Maximum = newVal;
            }
            return(ctrl);
        }
        // https://stackoverflow.com/questions/9201859/why-doesnt-type-getfields-return-backing-fields-in-a-base-class
        private static FieldInfo[] GetFieldsIncludingBaseClasses(Type type, DisplayOption displayOptions, BindingFlags bindingFlags)
        {
            FieldInfo[] fieldInfos    = type.GetFields(bindingFlags);
            var         fields        = displayOptions.IsSet(DisplayOption.Fields);
            var         backingFields = displayOptions.IsSet(DisplayOption.BackingFields);

            var fieldInfoList = new HashSet <FieldInfo>(fieldInfos, FieldInfoEqualityComparer);

            if (displayOptions.IsSet(DisplayOption.Inherited) && type.BaseType != typeof(object))
            {
                // collect all types up to the furthest base class
                var currentType = type;
                while (currentType != typeof(object))
                {
                    fieldInfos = currentType.GetFields(bindingFlags);
                    fieldInfoList.UnionWith(fieldInfos);
                    currentType = currentType.BaseType;
                }
            }

            if (!backingFields)
            {
                fieldInfoList.RemoveWhere(info => info.Name.EndsWith(BackingFieldSuffix));
            }

            if (!fields)
            {
                fieldInfoList.RemoveWhere(info => !info.Name.EndsWith(BackingFieldSuffix));
            }

            return(fieldInfoList.ToArray());
        }
        private static FrameworkElement ExtractDouble(DisplayOption option)
        {
            var ctrl = new DoubleUpDown
            {
                FormatString        = "F2",
                Margin              = new Thickness(3),
                HorizontalAlignment = HorizontalAlignment.Left,
                MinWidth            = 50
            };

            ctrl.SetBinding(DoubleUpDown.ValueProperty, new Binding(option.PropertyName));

            double newVal;

            if (option.Minimum != null)
            {
                newVal       = Convert.ToDouble(option.Minimum);
                ctrl.Minimum = newVal;
            }
            if (option.Maximum != null)
            {
                newVal       = Convert.ToDouble(option.Maximum);
                ctrl.Maximum = newVal;
            }

            return(ctrl);
        }
示例#6
0
        public IPluginOptionViewModel Construct(IOption option)
        {
            if (option is IListOption)
            {
                var optionType = option.GetType().FindBaseType(typeof(ListOption <>));
                if (optionType != null)
                {
                    var tValue  = optionType.GetGenericArguments().First();
                    var generic = _constructListOptionMethodInfo.MakeGenericMethod(tValue);

                    var opt = generic.Invoke(this, new object?[] { option });
                    if (opt != null)
                    {
                        return((IPluginOptionViewModel)opt);
                    }
                }
            }

            return(option switch
            {
                BooleanOption bOption => new PluginBooleanOptionViewModel(bOption, _localizationProvider),
                NumberOption nOption => new PluginNumberOptionViewModel(nOption, _localizationProvider),
                TextOption tOption => new PluginTextOptionViewModel(tOption, _localizationProvider),
                CommandOption cOption => new PluginCommandOptionViewModel(cOption, _localizationProvider),
                EncryptedTextOption eOption => new PluginEncryptedTextOptionViewModel(eOption, _localizationProvider),
                StringCollectionOption sOption => new PluginStringCollectionOptionViewModel(sOption, _localizationProvider),
                DisplayOption dOption => new PluginDisplayOptionViewModel(dOption, _localizationProvider),

                _ => ConstructDisplayOption(option)
            });
示例#7
0
        public static string GetNewsletterColumns(this HtmlHelper html, ContentAreaItem content, out int columns)
        {
            var newsletterColumn = NewsletterColumns.twelve;

            DisplayOption displayOption = content.LoadDisplayOption();

            if (displayOption != null)
            {
                switch (displayOption.Tag)
                {
                case WebGlobal.ContentAreaTags.FullWidth:
                    newsletterColumn = NewsletterColumns.twelve;
                    break;

                case WebGlobal.ContentAreaTags.TwoThirdsWidth:
                    newsletterColumn = NewsletterColumns.eight;
                    break;

                case WebGlobal.ContentAreaTags.HalfWidth:
                    newsletterColumn = NewsletterColumns.six;
                    break;

                case WebGlobal.ContentAreaTags.OneThirdWidth:
                    newsletterColumn = NewsletterColumns.four;
                    break;

                case WebGlobal.ContentAreaTags.Slider:
                    newsletterColumn = NewsletterColumns.twelve;
                    break;
                }
            }
            columns = (int)newsletterColumn;
            return(newsletterColumn.ToString());
        }
        private void DrawUpdateIntervalSlider(bool editor)
        {
            GUILayout.BeginHorizontal();

            GUILayout.Label("Update interval: ");
            GUILayout.BeginVertical();
            if (!editor)
            {
                GUILayout.Space(10f);
            }
            childrenUpdateInterval = GUILayout.HorizontalSlider(childrenUpdateInterval, 0.01f, 1f, UpdateIntervalSliderLayout);
            GUILayout.EndVertical();
            GUILayout.Label(childrenUpdateInterval.ToString());
            GUILayout.FlexibleSpace();

            var labels            = DisplayOptionUtils.Names;
            var oldDisplayOptions = displayOptions;

            for (int i = 0; i < labels.Length; i++)
            {
                bool enabled = displayOptions.IsSet(i);
                enabled        = GUILayout.Toggle(enabled, labels[i]);
                displayOptions = displayOptions.With(i, enabled);
            }

            ClearFieldInfoCacheIfNecessary(oldDisplayOptions);

            GUILayout.EndHorizontal();
        }
示例#9
0
        public PluginDisplayOptionViewModel(DisplayOption displayOption, ILocalizationProvider localizationProvider)
            : base(displayOption.NameTextId, displayOption.DescriptionTextId)
        {
            _pluginOptionViewModelImplementation = new PluginOptionViewModelImplementation(displayOption, localizationProvider, this);
            _value = displayOption.Value;

            displayOption.ValueChanged += (s, e) => Value = displayOption.Value;
        }
        public IEnumerator <Element> GetChildren(object obj, DisplayOption displayOptions)
        {
            componentResults.Clear();
            GameObject go = (GameObject)obj;

            go.GetComponents(componentResults);
            return(ComponentAndChildrenEnumerator(go, componentResults));
        }
        private static FrameworkElement ExtractNullableBool(DisplayOption option)
        {
            var ctrl = new CheckBox {
                IsThreeState = true, Style = (Style)Application.Current.Resources["YesNoInheritCheckbox"]
            };

            ctrl.SetBinding(ToggleButton.IsCheckedProperty, new Binding(option.PropertyName));
            return(ctrl);
        }
        public RdpOption()
        {
            _options = new Dictionary <string, object>();

            General       = new GeneralOption(_options);
            Display       = new DisplayOption(_options);
            LocalResource = new LocalResourceOption(_options);
            Experience    = new ExperienceOption(_options);
            Detail        = new DetailOption(_options);
        }
        private BindingFlags GetBindingFlags(DisplayOption displayOptions)
        {
            var bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;

            if (!displayOptions.IsSet(DisplayOption.Inherited))
            {
                bindingFlags |= BindingFlags.DeclaredOnly;
            }
            return(bindingFlags);
        }
        public static void ExtractOptions([NotNull] object ent, DisplayOptionList dict)
        {
            if (ent == null)
            {
                throw new ArgumentNullException("ent");
            }

            var eType = ent.GetType();

            if (_cachedTypes.ContainsKey(eType))
            {
                foreach (var type in _cachedTypes[eType])
                {
                    dict[type.Key] = type.Value;
                }

                return;
            }

            var props = eType.GetProperties();

            _cachedTypes[eType] = new DisplayOptionList();
            foreach (var info in props.Reverse())
            {
                if (!System.Attribute.IsDefined(info, typeof(EntityDescriptorAttribute)))
                {
                    continue;
                }
                var prop = (EntityDescriptorAttribute)info.GetCustomAttribute(typeof(EntityDescriptorAttribute));

                if (!dict.ContainsKey(prop.Category))
                {
                    dict.Add(prop.Category, new List <DisplayOption>());
                }
                if (!_cachedTypes[eType].ContainsKey(prop.Category))
                {
                    _cachedTypes[eType].Add(prop.Category, new List <DisplayOption>());
                }

                object min = null, max = null;
                var    multiline = System.Attribute.IsDefined(info, typeof(MultilineStringAttribute));

                if (System.Attribute.IsDefined(info, typeof(MinMaxAttribute)))
                {
                    var att = (MinMaxAttribute)info.GetCustomAttribute(typeof(MinMaxAttribute));
                    min = att.Minimum;
                    max = att.Maximum;
                }

                var displayOption = new DisplayOption(prop.Name, info.Name, info.PropertyType, prop.Description, min, max, multiline, prop.IsEnabledPath, prop.FixedSize, prop.DataGridRowHeaderPath, prop.Wide);

                _cachedTypes[eType][prop.Category].Insert(0, displayOption);
                dict[prop.Category].Insert(0, displayOption);
            }
        }
示例#15
0
        public static void Display(DisplayOption option, string toMatch = "")
        {
            switch (option)
            {
            case DisplayOption.All:
                foreach (Course course in courses)
                {
                    Console.WriteLine(course);
                }
                break;

            case DisplayOption.Code:
                foreach (Course course in courses)
                {
                    if (toMatch == "" || course.Code == toMatch)
                    {
                        Console.WriteLine(course);
                    }
                }
                break;

            case DisplayOption.Name:
                foreach (Course course in courses)
                {
                    if (toMatch == "" || course.Name == toMatch)
                    {
                        Console.WriteLine(course);
                    }
                }
                break;

            case DisplayOption.Prerequisite:
                foreach (Course course in courses)
                {
                    if (toMatch == "" || course.Prerequisites.Contains(toMatch))
                    {
                        Console.WriteLine(course);
                    }
                }
                break;

            case DisplayOption.Semester:
                foreach (Course course in courses)
                {
                    if (toMatch == "" || course.Semester.ToString() == toMatch)
                    {
                        Console.WriteLine(course);
                    }
                }
                break;

            default:
                throw new ArgumentOutOfRangeException("option", option, "not a valid value for DisplayOption");
            }
        }
示例#16
0
 public static DisplayOption With(this DisplayOption flags, DisplayOption value, bool enabled)
 {
     if (enabled)
     {
         return(flags | value);
     }
     else
     {
         return(flags & ~value);
     }
 }
示例#17
0
        public void ConstructorShouldSetCorrectValue(string expected)
        {
            // Arrange
            var sut = new DisplayOption(expected, "name", "description");

            // Act
            var actual = sut.Value;

            // Assert
            Assert.Equal(expected, actual);
        }
示例#18
0
        // PROPERTIES: No-Properties

        // CONSTRUCTOR: No-Constructor

        // METHODS
        public static void Display(DisplayOption option, string toMatch = "")
        {
            switch (option)
            {
            case DisplayOption.All:
                foreach (Course c in courses)
                {
                    Console.WriteLine(c);
                }
                break;

            case DisplayOption.Code:
                foreach (Course c in courses)
                {
                    if (c.Code == toMatch)
                    {
                        Console.WriteLine(c);
                    }
                }
                break;

            case DisplayOption.Name:
                foreach (Course c in courses)
                {
                    if (c.Name == toMatch)
                    {
                        Console.WriteLine(c);
                    }
                }
                break;

            case DisplayOption.Prerequisite:
                foreach (Course c in courses)
                {
                    // This [c.Prerequisites.Contains(toMatch)] is for checking the property has contain specific second argument
                    if (c.Prerequisites.Contains(toMatch))
                    {
                        Console.WriteLine(c);
                    }
                }
                break;

            case DisplayOption.Semester:
                foreach (Course c in courses)
                {
                    if (c.Semester == Convert.ToInt32(toMatch))
                    {
                        Console.WriteLine(c);
                    }
                }
                break;
            }
        }
        // METHODS
        public static void Display(DisplayOption option, string toMatch = "")
        {
            switch (option)
            {
            case DisplayOption.All:
                foreach (Course x in courses)
                {
                    Console.WriteLine(x);
                }
                break;

            case DisplayOption.Code:
                foreach (Course x in courses)
                {
                    if (x.Code == toMatch)
                    {
                        Console.WriteLine(x);
                    }
                }
                break;

            case DisplayOption.Name:
                foreach (Course x in courses)
                {
                    if (x.Name == toMatch)
                    {
                        Console.WriteLine(x);
                    }
                }
                break;

            case DisplayOption.Prerequisite:
                foreach (Course x in courses)
                {
                    if (x.Prerequisite == toMatch)
                    {
                        Console.WriteLine(x);
                    }
                }
                break;

            case DisplayOption.Semester:
                foreach (Course x in courses)
                {
                    if (x.Semester == Convert.ToInt32(toMatch))
                    {
                        Console.WriteLine(x);
                    }
                }
                break;
            }
        }
示例#20
0
        //METHODS

        /* Display(); displays the information searched
         * Two parameters: DisplayOption data type holds the filter chosen
         *               : toMatch holds a search word (optional)
         */

        public static void Display(DisplayOption option, string toMatch = "")
        {
            //If not match, displaying a message to the console
            bool noMatch = false;

            for (int i = 1; i < Enum.GetNames(typeof(DisplayOption)).Length; i++)
            {
                if (!Enum.GetName(typeof(DisplayOption), i).Contains(toMatch))
                {
                    noMatch = true;
                }
                else
                {
                    noMatch = false;
                }
            }

            if (noMatch)
            {
                Console.WriteLine("There is no match for your search.");
            }

            //Loop going through all of the info (items) contained in the courses list
            foreach (Course course in courses)
            {
                //Searching for one of the conditions below to be true
                if (option == DisplayOption.All)
                {
                    Console.WriteLine(course);
                }

                if (option == DisplayOption.Prerequsites && course.Prerequsites.Contains(toMatch))
                {
                    Console.WriteLine(course);
                }

                if (option == DisplayOption.Name && course.Name.Contains(toMatch))
                {
                    Console.WriteLine(course);
                }

                if (option == DisplayOption.Code && course.Code.Contains(toMatch))
                {
                    Console.WriteLine(course);
                }

                if (option == DisplayOption.Semester && Convert.ToString(course.Semester).Contains(toMatch))
                {
                    Console.WriteLine(course);
                }
            }
        }
        private IEnumerable <Element> GetFields(object obj, DisplayOption displayOptions)
        {
            var type = obj.GetType();

            FieldInfo[] fieldInfos;
            if (!typeToFieldInfos.TryGetValue(type, out fieldInfos))
            {
                fieldInfos = GetFieldsIncludingBaseClasses(type, displayOptions, GetBindingFlags(displayOptions));
                Array.Sort(fieldInfos, FieldInfoComparer);
                typeToFieldInfos[type] = fieldInfos;
            }
            return(FieldsEnumerator(fieldInfos, obj));
        }
        private static FrameworkElement ExtractItem(DisplayOption option)
        {
            var ctrl = new ItemControl {
                Margin = new Thickness(3)
            };

            ctrl.SetBinding(FrameworkElement.DataContextProperty, new Binding(option.PropertyName));
            if (option.Wide)
            {
                ctrl.SetValue(Grid.ColumnSpanProperty, 2);
            }
            return(ctrl);
        }
示例#23
0
        void ToggleDebugDisplayOption()
        {
            switch (displayOption)
            {
            case DisplayOption.COLOR:
                displayOption = DisplayOption.DEPTH;
                break;

            case DisplayOption.DEPTH:
                displayOption = DisplayOption.COLOR;
                break;
            }
        }
示例#24
0
文件: Form1.cs 项目: AdamDIOM/NEA
        private void TitleScreen(/*ref DisplayOption ShowMenu, */ TableLayoutPanel tblLayout)
        {
            /*creates a lable for the title, aligns it to the centre, adds the text,
             * sets autosize and anchors for resizing with window, sets font
             * and sets location to the the centre of the page spanning 5 columns
             */
            Label lblTitle = new Label();

            lblTitle.Text      = "RPG Designer and Player";
            lblTitle.TextAlign = ContentAlignment.MiddleCenter;
            lblTitle.Name      = "lblTitle";
            lblTitle.AutoSize  = true;
            lblTitle.Anchor    = (AnchorStyles.Left | AnchorStyles.Right);
            lblTitle.Font      = new Font(FontFamily.GenericSansSerif, 24.0F, FontStyle.Bold);
            lblTitle.Location  = new Point(this.Width / 2 - 2 * lblTitle.Width, 50);
            tblLayout.SetColumnSpan(lblTitle, 5);
            //adds the title to thye table
            tblLayout.Controls.Add(lblTitle, 0, 0);

            /*creates a button for the Designer option, adds it to the table
             * and sets anchors for auto resizing*/
            Button btnDesigner = new Button();

            btnDesigner.Text = "Designer";
            // sort this out
            //btnDesigner.Click += ;
            tblLayout.Controls.Add(btnDesigner, 1, 2);
            btnDesigner.Anchor = (AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom);

            /*creates a button for the Play option, adds it to the table
             * and sets anchors for auto resizing*/
            Button btnPlay = new Button();

            btnPlay.Text   = "Play";
            btnPlay.Click += new EventHandler((sender, e) => ShowMenu = new DisplayOption(PlayScreen));
            tblLayout.Controls.Add(btnPlay, 3, 2);
            btnPlay.Anchor = (AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom);

            /*creates a button to quit, adds it to the table, adds EventHandler to quit
             * and sets anchors for auto resizing*/
            Button btnQuit = new Button();

            btnQuit.Text   = "Quit";
            btnQuit.Click += new EventHandler(Quit);
            tblLayout.Controls.Add(btnQuit, 2, 4);
            btnQuit.Anchor = (AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom);

            /*ShowMenu = new DisplayOption(InitialiseTable);
             * used for testing only
             */
        }
        private IEnumerable <Element> GetProperties(object obj, DisplayOption displayOptions)
        {
            var            type = obj.GetType();
            TypeProperties typeProperties;

            if (!typeToProperties.TryGetValue(type, out typeProperties))
            {
                var propertyInfos = type.GetProperties(GetBindingFlags(displayOptions));
                Array.Sort(propertyInfos, PropertyInfoComparer);
                typeProperties         = new TypeProperties(propertyInfos);
                typeToProperties[type] = typeProperties;
            }
            return(PropertiesEnumerator(typeProperties, obj));
        }
        private static FrameworkElement ExtractGeneric(DisplayOption option)
        {
            var ctrl = new ContentPresenter {
                Margin = new Thickness(3)
            };

            ctrl.SetBinding(ContentPresenter.ContentProperty, new Binding(option.PropertyName));
            if (option.Wide)
            {
                ctrl.SetValue(Grid.ColumnSpanProperty, 2);
            }

            return(ctrl);
        }
        private static FrameworkElement ExtractEnum(DisplayOption option)
        {
            var ctrl = new ComboBox {
                Margin = new Thickness(3)
            };
            var m  = typeof(EnumHelper).GetMethod("GetAllValuesAndDescriptions").MakeGenericMethod(option.PropertyType);
            var ie = m.Invoke(null, null) as IEnumerable;

            ctrl.ItemsSource       = ie;
            ctrl.DisplayMemberPath = "Description";
            ctrl.SetBinding(Selector.SelectedValueProperty, new Binding(option.PropertyName));
            ctrl.SelectedValuePath = "Value";
            return(ctrl);
        }
        private void ClearFieldInfoCacheIfNecessary(DisplayOption oldDisplayOptions)
        {
            var fieldsChanged = oldDisplayOptions.IsSet(DisplayOption.Fields)
                                != displayOptions.IsSet(DisplayOption.Fields);
            var backingFieldsChanged = oldDisplayOptions.IsSet(DisplayOption.BackingFields)
                                       != displayOptions.IsSet(DisplayOption.BackingFields);
            var inheritedChanged = oldDisplayOptions.IsSet(DisplayOption.Inherited)
                                   != displayOptions.IsSet(DisplayOption.Inherited);

            if (fieldsChanged || backingFieldsChanged || inheritedChanged)
            {
                model.ClearObjectHandlerFieldInfoCache();
            }
        }
示例#29
0
        public static string GetNewsletterImageWidth(this HtmlHelper html, ContentAreaItem content, bool halfWidth = false)
        {
            DisplayOption displayOption = content.LoadDisplayOption();

            if (!halfWidth)
            {
                if (displayOption != null)
                {
                    switch (displayOption.Tag)
                    {
                    case WebGlobal.ContentAreaTags.FullWidth:
                        return(ImageFile.NewsletterWidths.FULL);

                    case WebGlobal.ContentAreaTags.TwoThirdsWidth:
                        return(ImageFile.NewsletterWidths.WIDE);

                    case WebGlobal.ContentAreaTags.HalfWidth:
                        return(ImageFile.NewsletterWidths.HALF);

                    case WebGlobal.ContentAreaTags.OneThirdWidth:
                        return(ImageFile.NewsletterWidths.NARROW);
                    }
                }
                return(ImageFile.NewsletterWidths.FULL);
            }
            else
            {
                if (displayOption != null)
                {
                    switch (displayOption.Tag)
                    {
                    case WebGlobal.ContentAreaTags.FullWidth:
                        return(ImageFile.NewsletterWidths.HALF);

                    case WebGlobal.ContentAreaTags.TwoThirdsWidth:
                        return(ImageFile.NewsletterWidths.NARROW);

                    case WebGlobal.ContentAreaTags.HalfWidth:
                        return(ImageFile.NewsletterWidths.NARROW);

                    case WebGlobal.ContentAreaTags.OneThirdWidth:
                        return(ImageFile.NewsletterWidths.NARROW);
                    }
                }
                return(ImageFile.NewsletterWidths.HALF);
            }
        }
        private static FrameworkElement ExtractString(DisplayOption option)
        {
            var ctrl = new TextBox {
                Margin = new Thickness(3)
            };

            if (option.Multiline)
            {
                ctrl.TextWrapping  = TextWrapping.Wrap;
                ctrl.AcceptsReturn = true;
                ctrl.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
                ctrl.MinHeight = 100;
            }

            ctrl.SetBinding(TextBox.TextProperty, new Binding(option.PropertyName));
            return(ctrl);
        }
示例#31
0
        public static void Display(DisplayOption option, string toMatch = "")
        {
            if(option == DisplayOption.All){
                foreach (var i in courses)
                    Console.WriteLine(i.ToString());
            }
            else if (option == DisplayOption.Prerequsite){
                foreach (var i in courses)
                {
                    if(i.Prerequsite.Contains(toMatch))
                        Console.WriteLine(i.ToString());
                }
            }
            else if (option == DisplayOption.Code)
            {
                foreach (var i in courses)
                {
                    if (i.Code.Contains(toMatch))
                        Console.WriteLine(i.ToString());
                }
            }

            else if (option == DisplayOption.Name)
            {
                foreach (var i in courses)
                {
                    if (i.Name.Contains(toMatch))
                        Console.WriteLine(i.ToString());
                }
            }

            else if (option == DisplayOption.Semester)
            {
                foreach (var i in courses)
                {
                    int match = Convert.ToInt32(toMatch);
                    if (i.Semester == match)
                        Console.WriteLine(i.ToString());
                }
            }
        }
示例#32
0
    public void Display(string name, DisplayOption opt)
    {
        Console.WriteLine("{0,-3}|{1,-15}|{2,-15}", "N", "Title", "Author");
        for (int i = 0; i < this.bookList.Count; i++)
        {

            if (opt == DisplayOption.Author)
            {
                if (this.bookList[i].Author == name)
                {
                    Console.WriteLine("{0,-3}|{1,-15}|{2,-15}", i + 1, bookList[i].Title, bookList[i].Author);
                }
            }
            else
            {
                if (this.bookList[i].Title == name)
                {
                    Console.WriteLine("{0,-3}|{1,-15}|{2,-15}", i + 1, bookList[i].Title, bookList[i].Author);
                }
            }
        }
    }
示例#33
0
		/// <summary>
		/// Adds an insertion option. A predicate can be provided to determine in what contexts
		/// this insertion option can be displayed.
		/// </summary>
		/// <param name="type">The type.</param>
		/// <param name="shouldDisplay">The should display predicate.</param>
		public void AddOption(RuleInsertType type, DisplayOption shouldDisplay)
		{
			CheckDisposed();

			m_options.Add(new InsertOption(type, shouldDisplay, null));
		}
 public static void Display(DisplayOption option, string toMatch)
 {
 }
 public static void Display(DisplayOption option)
 {
     for (int i = 0; i < courses.Count; i++){
         Console.WriteLine(courses[i]);
     }
 }
示例#36
0
			public InsertOption(RuleInsertType type, DisplayOption shouldDisplay, DisplayIndices displayIndices)
			{
				this.type = type;
				this.shouldDisplay = shouldDisplay;
				this.displayIndices = displayIndices;
			}
示例#37
0
		/// <summary>
		/// Adds an index option. A predicate can be provided to determine what indices to display.
		/// </summary>
		/// <param name="shouldDisplay">The should display predicate.</param>
		/// <param name="displayIndices">The display indices predicate.</param>
		public void AddIndexOption(DisplayOption shouldDisplay, DisplayIndices displayIndices)
		{
			CheckDisposed();

			m_options.Add(new InsertOption(RuleInsertType.INDEX, shouldDisplay, displayIndices));
		}
 private void UpdateDisplayProperties(ToolType toolType)
 {
     if (CurrentGame.ToolIsActive)
     {
         SetDisplayValues(toolType);
         SetDisplayTexture(toolType);
     }
     else
     {
         _displayOption = DisplayOption.DoNotDisplay;
     }
 }
示例#39
0
 /// <summary>
 /// Determines whether the passed error text needs to be logged and logs
 /// it if necessary.
 /// </summary>
 /// <param name="errText">The text of the error to be logged.</param>
 /// <param name="display">A value that determines when the error message
 /// should be displayed in a messagebox.</param>
 /// <returns>False.</returns>
 /// <remarks>
 /// <para>Errors will be logged in "My Documents\(AppName).err" and will
 /// also be sent to the debug logger with severity = alarm.</para>
 /// <para>Note that this method only returns a value to facilitate its 
 /// use in the VB.Net <c>Catch ... When (condition)</c> construct.</para>
 /// </remarks>
 public static bool LogError(string errText, DisplayOption display)
 {
     errText = string.Format(ResStrings.GetString("Thread"),
                             Thread.CurrentThread.Name,
                             Thread.CurrentThread.ManagedThreadId.ToString()) + "\r\n" + errText;
     PurgeOldErrors();
     if (IsLogDuplicate(errText)) {
         // Not logging: only display error if user selected.
         if (display == DisplayOption.Always)
             DisplayToScreen(errText);
     } else {
         // Log the error and add to remembered errors collection
         LogToFile(errText);
         DebugLogger.LogAction(ResStrings.GetString("UnhandledError"), errText, LoggingLevels.Alarm);
         LoggedError errNew = new LoggedError();
         errNew.ErrorMessage = errText;
         loggedErrors.Add(errNew);
         // Now display the error if required
         if (display != DisplayOption.Never)
             DisplayToScreen(errText);
     }
     return false;
 }
示例#40
0
 /// <summary>
 /// Determines whether the passed exception needs to be logged and logs 
 /// it if necessary.
 /// </summary>
 /// <param name="e">The exception to be logged.</param>
 /// <param name="display">A value that determines when the error message
 /// should be displayed in a messagebox.</param>
 /// <returns>False.</returns>
 /// <remarks>
 /// <para>Errors will be logged in "My Documents\(AppName).err" and will
 /// also be sent to the debug logger with severity = alarm.</para>
 /// <para>The message that gets logged is identical to what you would 
 /// get if you had called:</para>
 /// <para><c>LogError(e.ToString(), display);</c></para>
 /// <para>Note that this method only returns a value to facilitate its 
 /// use in the VB.Net <c>Catch ... When (condition)</c> construct.</para>
 ///</remarks>
 public static bool LogError(Exception e, DisplayOption display)
 {
     LogError(e.ToString(), display);
     return false;
 }
示例#41
0
 void ToggleDebugDisplayOption() {
   switch (displayOption) {
     case DisplayOption.COLOR:
       displayOption = DisplayOption.DEPTH;
       break;
     case DisplayOption.DEPTH:
       displayOption = DisplayOption.COLOR;
       break;
   }
 }
 private void SetDisplayValues(ToolType toolType)
 {
     switch (toolType)
     {
         case ToolType.Invincibility: _displayOption = DisplayOption.DisplayTimer; _totalTime = Constants.Invincibility_Duration; break;
         case ToolType.Jetpack: _displayOption = DisplayOption.DisplayTimer; _totalTime = Constants.Jetpack_Duration; break;
         case ToolType.SuperJump: _displayOption = DisplayOption.DisplayOneShot; break;
         case ToolType.FirepowerUp: _displayOption = DisplayOption.DisplayTimer; break;
         case ToolType.Pickaxe: _displayOption = DisplayOption.DisplayTimer; _totalTime = Constants.Pickaxe_Duration; break;
         case ToolType.FireExtinguisher: _displayOption = DisplayOption.DoNotDisplay; break;
     }
 }