상속: MonoBehaviour
예제 #1
1
        /// <summary>
        /// Initializes a new instance of the <see cref="WatermarkAdorner"/> class
        /// </summary>
        /// <param name="adornedElement"><see cref="UIElement"/> to be adorned</param>
        /// <param name="watermark">The watermark</param>
        public WatermarkAdorner(UIElement adornedElement, object watermark)
            : base(adornedElement)
        {
            IsHitTestVisible = false;

            contentPresenter = new ContentPresenter
            {
                Content = watermark,
                Opacity = 0.5,
                Margin = new Thickness(Control.Margin.Left + Control.Padding.Left, Control.Margin.Top + Control.Padding.Top, 0, 0)
            };

            if (Control is ItemsControl && !(Control is ComboBox))
            {
                contentPresenter.VerticalAlignment = VerticalAlignment.Center;
                contentPresenter.HorizontalAlignment = HorizontalAlignment.Center;
            }

            // Hide the control adorner when the adorned element is hidden
            var binding = new Binding("IsVisible")
            {
                Source = adornedElement,
                Converter = new BooleanToVisibilityConverter()
            };
            SetBinding(VisibilityProperty, binding);
        }
        public RemovedItemAdorner(UIElement adornedPanel, FrameworkElement adornedElement)
            : base(adornedPanel)
        {
            this.IsHitTestVisible = false;

            Width = Math.Ceiling(adornedElement.ActualWidth);
            Height = Math.Ceiling(adornedElement.ActualHeight);
            
            var offset = VisualTreeHelper.GetOffset(adornedElement);
            
            _border = new Border 
            { 
                Background = new VisualBrush(adornedElement),                 
                Width = adornedElement.ActualWidth, 
                Height = adornedElement.ActualHeight,
                RenderTransform = new TranslateTransform
                {
                    X = offset.X,
                    Y = offset.Y,
                }
            };

            // HACK: Need to figure out why this doesn't work
            _border.Width = 50;
            _border.Height = 40;

            AddVisualChild(_border);

            Loaded += RemovedItemAdorner_Loaded;
        }
예제 #3
0
        private void buttonScanCustom_Click(object sender, RoutedEventArgs e)
        {
            //Get our UIElement from the MainPage.xaml (this) file
            // to use as our custom overlay
            if (customOverlayElement == null)
            {
                customOverlayElement = this.customOverlay.Children[0];
                this.customOverlay.Children.RemoveAt(0);
            }

            //Wireup our buttons from the custom overlay
            this.buttonCancel.Click += (s, e2) =>
            {
                scanner.Cancel();
            };
            this.buttonFlash.Click += (s, e2) =>
            {
                scanner.ToggleTorch();
            };

            //Set our custom overlay and enable it
            scanner.CustomOverlay = customOverlayElement;
            scanner.UseCustomOverlay = true;

            //Start scanning
            scanner.Scan().ContinueWith(t =>
            {
                if (t.Result != null)
                    HandleScanResult(t.Result);
            });
        }
예제 #4
0
		public WriteableBitmap (UIElement element, Transform transform) :
			base (SafeNativeMethods.writeable_bitmap_new (), true)
		{
			if (element == null)
				throw new ArgumentNullException ("element");

			Rect bounds = new Rect ();
			// Width and Height are defined in FrameworkElement - but it's unlikely to be an "unknown" UIElement
			// descendant since there's no usable ctor to inherit from it (at least outside S.W.dll)
			FrameworkElement fe = (element as FrameworkElement);
			if (fe != null) {
				bounds.Width = fe.ActualWidth;
				bounds.Height = fe.ActualHeight;
			}

			if (transform != null)
				bounds = transform.TransformBounds (bounds);

			AllocatePixels (Double.IsNaN (bounds.Width) ? 0 : (int) bounds.Width, Double.IsNaN (bounds.Height) ? 0 : (int) bounds.Height);
			PinAndSetBitmapData ();

			Invalidate ();

			Render (element, transform);
		}
 public BeginStoryboard FindStoryboard(UIElement element)
 {
   INameScope ns = FindNameScope();
   if (ns != null)
     return ns.FindName(BeginStoryboardName) as BeginStoryboard;
   return null;
 }
예제 #6
0
		public ToolBarButton(UIElement inputBindingOwner, Codon codon, object caller, bool createCommand, IReadOnlyCollection<ICondition> conditions)
		{
			ToolTipService.SetShowOnDisabled(this, true);
			
			this.codon = codon;
			this.caller = caller;
			if (createCommand)
				this.Command = CommandWrapper.CreateCommand(codon, conditions);
			else
				this.Command = CommandWrapper.CreateLazyCommand(codon, conditions);
			this.CommandParameter = caller;
			this.Content = ToolBarService.CreateToolBarItemContent(codon);
			this.conditions = conditions;

			if (codon.Properties.Contains("name")) {
				this.Name = codon.Properties["name"];
			}

			if (!string.IsNullOrEmpty(codon.Properties["shortcut"])) {
				KeyGesture kg = MenuService.ParseShortcut(codon.Properties["shortcut"]);
				MenuCommand.AddGestureToInputBindingOwner(inputBindingOwner, kg, this.Command, GetFeatureName());
				this.inputGestureText = MenuService.GetDisplayStringForShortcut(kg);
			}
			UpdateText();
			
			SetResourceReference(FrameworkElement.StyleProperty, ToolBar.ButtonStyleKey);
		}
예제 #7
0
        private VisualCollection _visualChildren; //visual children.

        #endregion Fields

        #region Constructors

        public EditBoxAdorner(EditBox editBox, UIElement adornedElement)
            : base(adornedElement)
        {
            _editBox = editBox;
            _visualChildren = new VisualCollection(this);
            BuildTextBox();
        }
예제 #8
0
 public UiPrintHelper(int verticalOffset, int horizontalOffset, string title, UIElement content)
 {
     VerticalOffset = verticalOffset;
     HorizontalOffset = horizontalOffset;
     Title = title;
     Content = content;
 }
예제 #9
0
 public void BeginLinesRemove(UIElement element)
 {
     if (BeginLines.Contains(element))
     {
         BeginLines.Remove(element);
     }
 }
예제 #10
0
        public ZoomableInlineAdornment(UIElement content, ITextView parent, Size desiredSize) {
            _parent = parent;
            Debug.Assert(parent is IInputElement);
            _originalSize = _desiredSize = new Size(
                Math.Max(double.IsNaN(desiredSize.Width) ? 100 : desiredSize.Width, 10),
                Math.Max(double.IsNaN(desiredSize.Height) ? 100 : desiredSize.Height, 10)
            );

            // First time through, we want to reduce the image to fit within the
            // viewport.
            if (_desiredSize.Width > parent.ViewportWidth) {
                _desiredSize.Width = parent.ViewportWidth;
                _desiredSize.Height = _originalSize.Height / _originalSize.Width * _desiredSize.Width;
            }
            if (_desiredSize.Height > parent.ViewportHeight) {
                _desiredSize.Height = parent.ViewportHeight;
                _desiredSize.Width = _originalSize.Width / _originalSize.Height * _desiredSize.Height;
            }

            ContextMenu = MakeContextMenu();

            Focusable = true;
            MinWidth = MinHeight = 50;

            Children.Add(content);

            GotFocus += OnGotFocus;
            LostFocus += OnLostFocus;
        }
예제 #11
0
파일: Drag.cs 프로젝트: jsmithorg/Dragging
        public static void Start(UIElement element)
        {
            if (Element != null)
                throw new Exception("Another element is being dragged.  Only one element at a time may be dragged.");

            Element = element;
            Element.CaptureMouse();
            Element.MouseMove += new MouseEventHandler(UIElement_MouseMove);

            TransformGroup tg = Element.RenderTransform as TransformGroup;
            if (tg == null)
            {
                tg = CreateTransformGroup();
                Element.RenderTransform = tg;

            }//end if

            TranslateTransform tt = tg.Children.Where(t => t is TranslateTransform).SingleOrDefault() as TranslateTransform;
            if (tt == null)
                tt = new TranslateTransform();

            tt.X = 0;
            tt.Y = 0;

            OnDragStarted(Element);
        }
예제 #12
0
 // The constructor which takes a FrameworkElement array.
 internal ElementsClipboardData(UIElement[] elements)
 {
     if ( elements != null ) 
     {
         ElementList = new List<UIElement>(elements); 
     } 
 }
예제 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DropPreviewAdorner"/> class.
 /// </summary>
 /// <param name="feedbackUI">The UI element used as feedback element.</param>
 /// <param name="adornedElement">The element to bind the adorner to.</param>
 public DropPreviewAdorner(UIElement feedbackUI, UIElement adornedElement)
     : base(adornedElement)
 {
     m_Presenter = new ContentPresenter();
     m_Presenter.Content = feedbackUI;
     m_Presenter.IsHitTestVisible = false;
 }
예제 #14
0
        public static bool GetCanBeDragged(UIElement uiElement)
        {
            if (uiElement == null)
                return false;

            return (bool)uiElement.GetValue(CanBeDraggedProperty);
        }
예제 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemplatedAdorner"/> class.
 /// </summary>
 /// <param name="adornedElement">The adorned element.</param>
 /// <param name="dataContext">The data context.</param>
 /// <param name="adornerTemplate">The adorner template.</param>
 public TemplatedAdorner(UIElement adornedElement, object dataContext, ControlTemplate adornerTemplate)
     : base(adornedElement)
 {
     _child = new Control {Template = adornerTemplate};
     DataContext = dataContext;
     AddVisualChild(_child);
 }
예제 #16
0
 private void ExpandViewPart(UIElement viewPart, Grid hostGrid)
 {
     hostGrid.Children.Remove(viewPart);
     this.Shelf.Children.Add(viewPart);
     Grid.SetColumn(viewPart, 0);
     Grid.SetColumnSpan(viewPart, 3);
 }
예제 #17
0
 /// <summary>
 /// Get the positions of an element in the grid as an <see cref="Int3"/>.
 /// </summary>
 /// <param name="element">The element from which extract the position values</param>
 /// <returns>The position of the element</returns>
 protected Int3 GetElementGridPositions(UIElement element)
 {
     return new Int3(
         element.DependencyProperties.Get(ColumnPropertyKey),
         element.DependencyProperties.Get(RowPropertyKey),
         element.DependencyProperties.Get(LayerPropertyKey));
 }
        /// <summary>
        /// Get the bounds of an element relative to another element.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="otherElement">
        /// The element relative to the other element.
        /// </param>
        /// <returns>
        /// The bounds of the element relative to another element, or null if
        /// the elements are not related.
        /// </returns>
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="element"/> is null.
        /// </exception>
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="otherElement"/> is null.
        /// </exception>
        public static Rect? GetBoundsRelativeTo(this FrameworkElement element, UIElement otherElement)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            if (otherElement == null)
            {
                throw new ArgumentNullException("otherElement");
            }

            try
            {
                Point origin, bottom;
                GeneralTransform transform = element.TransformToVisual(otherElement);
                if (transform != null &&
                    transform.TryTransform(new Point(), out origin) &&
                    transform.TryTransform(new Point(element.ActualWidth, element.ActualHeight), out bottom))
                {
                    return new Rect(origin, bottom);
                }
            }
            catch (ArgumentException)
            {
                // Ignore any exceptions thrown while trying to transform
            }

            return null;
        }
예제 #19
0
 internal static void SetLabelMaxMovingDistance(XYChartArea chartArea, UIElement element)
 {
     double maximumMovingDistance = 0.0;
     if (chartArea.Orientation == Orientation.Horizontal)
         maximumMovingDistance = 40.0;
     AnchorPanel.SetMaximumMovingDistance(element, maximumMovingDistance);
 }
예제 #20
0
 /// <summary>
 /// Get an element span values as an <see cref="Int3"/>.
 /// </summary>
 /// <param name="element">The element from which extract the span values</param>
 /// <returns>The span values of the element</returns>
 protected Int3 GetElementSpanValues(UIElement element)
 {
     return new Int3(
         element.DependencyProperties.Get(ColumnSpanPropertyKey),
         element.DependencyProperties.Get(RowSpanPropertyKey),
         element.DependencyProperties.Get(LayerSpanPropertyKey));
 }
예제 #21
0
 /// <summary>
 /// Sets the mouse handlers for element. Mouse hover handler is added to change the helpful text, and click handler is
 /// added to open the color picker.
 /// When the color is saved, it updates the theme, and applies it.
 /// </summary>
 /// <param name="themeKey">The theme key (as per the json theme).</param>
 /// <param name="hoverText">The hover text.</param>
 /// <param name="element">The element on which we add hover and click handlers.</param>
 private void SetMouseHandlersForElement(string themeKey, string hoverText, UIElement element)
 {
     if (element == null) {
         return;
     }
     // change the instruction text to hoverText
     element.IsMouseDirectlyOverChanged += (sender, e) =>
     {
         if (ViewModel.Editable && (bool) e.NewValue) {
             // mouse is now directly over this element, show the helpful text to the user so they know what they are hovering
             HoveredElementInfo.Text = hoverText;
             return;
         }
         // mouse is no longer directly over this element
         HoveredElementInfo.Text = "";
     };
     // handle onclick
     element.PreviewMouseDown += (sender, e) =>
     {
         // the rhs of the OR is a hack because TextBox elements have child element of TextBoxView (internal), its ugly, needs improvement
         var isCorrectElement = e.OriginalSource.Equals(element) ||
                                (element.GetType() == typeof (TextBox) &&
                                 e.OriginalSource.GetType().Name == "TextBoxView");
         if (ViewModel.Editable && isCorrectElement) {
             // mouse is now directly over this element, show the helpful text to the user so they know what they are hovering
             ViewModel.ShowColorPicker(Window.GetWindow(this), hoverText, themeKey);
             e.Handled = true;
         }
     };
 }
 private DisconnectedUIElementCollection(UIElement owner, SurrogateVisualParent surrogateVisualParent)
     : base(surrogateVisualParent, null)
 {
     _ownerPanel = owner as Panel;
     surrogateVisualParent.InitializeOwner(this);
     _elements = new Collection<UIElement>();
 }
        public ZoomableInlineAdornment(UIElement content, ITextView parent) {
            _parent = parent;
            Debug.Assert(parent is IInputElement);
            Content = new Border { BorderThickness = new Thickness(1), Child = content, Focusable = true };

            _zoom = 1.0;             // config.GetConfig().Repl.InlineMedia.MaximizedZoom
            _zoomStep = 0.25;        // config.GetConfig().Repl.InlineMedia.ZoomStep
            _minimizedZoom = 0.25;   // config.GetConfig().Repl.InlineMedia.MinimizedZoom
            _widthRatio = 0.67;      // config.GetConfig().Repl.InlineMedia.WidthRatio
            _heightRatio = 0.5;      // config.GetConfig().Repl.InlineMedia.HeightRatio

            _isResizing = false;
            UpdateSize();

            GotFocus += OnGotFocus;
            LostFocus += OnLostFocus;

            ContextMenu = MakeContextMenu();

            var trigger = new Trigger { Property = Border.IsFocusedProperty, Value = true };
            var setter = new Setter { Property = Border.BorderBrushProperty, Value = SystemColors.ActiveBorderBrush };
            trigger.Setters.Add(setter);

            var style = new Style();
            style.Triggers.Add(trigger);
            MyContent.Style = style;
        }
예제 #24
0
 public static Tuple<IObservable<Direction>, IObservable<Direction>> ToDirections(UIElement element)
 {
     return Tuple.Create(
         ToDirections(element, "KeyDown"),
         ToDirections(element, "KeyUp")
         );
 }
예제 #25
0
 void button_OnButtonClick(UIElement button)
 {
     if (data != null)
     {
         owner.SelectedItem = data;
     }
 }
        public void Initialize(UIElement element)
        {

            this.child = element;
            if (child != null)
            {
                TransformGroup group = new TransformGroup();

                ScaleTransform st = new ScaleTransform();
                group.Children.Add(st);

                TranslateTransform tt = new TranslateTransform();

                group.Children.Add(tt);

                child.RenderTransform = group;
                child.RenderTransformOrigin = new Point(0.0, 0.0);

                child.MouseWheel += child_MouseWheel;
                child.MouseLeftButtonDown += child_MouseLeftButtonDown;
                child.MouseLeftButtonUp += child_MouseLeftButtonUp;
                child.MouseMove += child_MouseMove;
                child.PreviewMouseRightButtonDown += new MouseButtonEventHandler(child_PreviewMouseRightButtonDown);
            }
        }
 private void AddChildrenToGrid(Grid grid, UIElement obj)
 {
     ColumnDefinition col = new ColumnDefinition();
     grid.ColumnDefinitions.Add(col);
     grid.Children.Add(obj);
     Grid.SetColumn(obj, grid.Children.Count - 1);
 }
예제 #28
0
		internal static void Start(ref InfoTextEnterArea grayOut, ServiceContainer services, UIElement activeContainer, Rect activeRectInActiveContainer, string text)
		{
			Debug.Assert(services != null);
			Debug.Assert(activeContainer != null);
			DesignPanel designPanel = services.GetService<IDesignPanel>() as DesignPanel;
			OptionService optionService = services.GetService<OptionService>();
			if (designPanel != null && grayOut == null && optionService != null && optionService.GrayOutDesignSurfaceExceptParentContainerWhenDragging) {
				grayOut = new InfoTextEnterArea();
				grayOut.designSurfaceRectangle = new RectangleGeometry(
					new Rect(0, 0, ((Border)designPanel.Child).Child.RenderSize.Width, ((Border)designPanel.Child).Child.RenderSize.Height));
				grayOut.designPanel = designPanel;
				grayOut.adornerPanel = new AdornerPanel();
				grayOut.adornerPanel.Order = AdornerOrder.Background;
				grayOut.adornerPanel.SetAdornedElement(designPanel.Context.RootItem.View, null);
				grayOut.ActiveAreaGeometry = new RectangleGeometry(activeRectInActiveContainer, 0, 0, (Transform)activeContainer.TransformToVisual(grayOut.adornerPanel.AdornedElement));
				var tb = new TextBlock(){Text = text};
				tb.FontSize = 10;
				tb.ClipToBounds = true;
				tb.Width = ((FrameworkElement) activeContainer).ActualWidth;
				tb.Height = ((FrameworkElement) activeContainer).ActualHeight;
				tb.VerticalAlignment = VerticalAlignment.Top;
				tb.HorizontalAlignment = HorizontalAlignment.Left;
				tb.RenderTransform = (Transform)activeContainer.TransformToVisual(grayOut.adornerPanel.AdornedElement);
				grayOut.adornerPanel.Children.Add(tb);
								
				designPanel.Adorners.Add(grayOut.adornerPanel);
			}
		}
예제 #29
0
        public void SetVisible(bool visible)
        {
            if (_isVisible != visible)
            {
                if (visible)
                {
                    // Сохранение контента
                    _parentContent = (UIElement)_parent.Content;

                    // Создание таблицы для инъекции в визуальное дерево
                    _grid = new Grid();
                    _parent.Content = _grid;
                    // Конфигурирование свойств
                    _parentContent.Opacity = 0.5;
                    _parentContent.IsEnabled = false;
                    // Инъекция таблицы
                    _grid.Children.Add(_parentContent);
                    _grid.Children.Add(this);
                }
                else
                {
                    _parentContent.Opacity = 1;
                    _parentContent.IsEnabled = true;
                    _grid.Children.Clear();
                    _parent.Content = _parentContent;
                }

                _isVisible = visible;
            }
        }
예제 #30
0
        private static void SetAnchorValue(UIElement e, int edge, int val)
        {
            e.VerifyAccess();

            UIElement.Pair anchorInfo = e._anchorInfo;
            if (anchorInfo == null)
            {
                anchorInfo = new UIElement.Pair();
                e._anchorInfo = anchorInfo;
            }

            if ((edge & Edge_LeftRight) != 0)
            {
                anchorInfo._first = val;
                anchorInfo._status &= ~Edge_LeftRight;
            }
            else
            {
                anchorInfo._second = val;
                anchorInfo._status &= ~Edge_TopBottom;
            }

            anchorInfo._status |= edge;

            if (e.Parent != null)
            {
                e.Parent.InvalidateArrange();
            }
        }
 public static void SetText(UIElement element, string value)
 {
     element.SetValue(TextProperty, value);
 }
 /// <summary>
 ///     显示元素
 /// </summary>
 /// <param name="element"></param>
 public static void Show(this UIElement element) => element.Visibility = Visibility.Visible;
예제 #33
0
 public static Visual GetElementVisual(this UIElement element)
 {
     return(ElementCompositionPreview.GetElementVisual(element));
 }
예제 #34
0
 private void DragSourceControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     DragBeginHelper.ElementOwningButtonDown = (UIElement)null;
 }
예제 #35
0
        public QuestDetailsScreen(QuestData.Quest q)
        {
            Game game = Game.Get();

            LocalizationRead.AddDictionary("qst", q.localizationDict);
            // If a dialog window is open we force it closed (this shouldn't happen)
            foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG))
            {
                Object.Destroy(go);
            }

            // Heading
            UIElement ui = new UIElement();

            ui.SetLocation(2, 0.5f, UIScaler.GetWidthUnits() - 4, 3);
            ui.SetText(q.name);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetLargeFont());

            // Draw Image
            if (q.image.Length > 0)
            {
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(-20), 4, 8, 8);
                ui.SetImage(ContentData.FileToTexture(Path.Combine(q.path, q.image)));
                new UIElementBorder(ui);
            }

            // Draw Description
            ui = new UIElement();
            float height = ui.GetStringHeight(q.description, 30);

            if (height > 25)
            {
                height = 25;
            }
            ui.SetLocation(UIScaler.GetHCenter(-7), 15 - (height / 2), 30, height);
            ui.SetText(q.description);
            new UIElementBorder(ui);

            // Draw authors
            ui     = new UIElement();
            height = ui.GetStringHeight(q.authors, 14);
            if (height > 25)
            {
                height = 25;
            }
            ui.SetLocation(UIScaler.GetHCenter(-23), 18.5f - (height / 2), 14, height);
            ui.SetText(q.authors);
            new UIElementBorder(ui);

            // Difficulty
            if (q.difficulty != 0)
            {
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(-13), 27, 11, 1);
                ui.SetText(new StringKey("val", "DIFFICULTY"));
                string symbol = "*";
                if (game.gameType is MoMGameType)
                {
                    symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate();
                }
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(-13), 28, 11, 2);
                ui.SetText(symbol + symbol + symbol + symbol + symbol);
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(-10.95f) + (q.difficulty * 6.9f), 28, (1 - q.difficulty) * 6.9f, 2);
                ui.SetBGColor(new Color(0, 0, 0, 0.7f));
            }

            // Duration
            if (q.lengthMax != 0)
            {
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(2), 27, 11, 1);
                ui.SetText(new StringKey("val", "DURATION"));

                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(2), 28, 4, 2);
                ui.SetText(q.lengthMin.ToString());
                ui.SetFontSize(UIScaler.GetMediumFont());

                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(6.5f), 28, 2, 2);
                ui.SetText("-");
                ui.SetFontSize(UIScaler.GetMediumFont());

                ui = new UIElement();
                ui.SetLocation(UIScaler.GetHCenter(9), 28, 4, 2);
                ui.SetText(q.lengthMax.ToString());
                ui.SetFontSize(UIScaler.GetMediumFont());
            }

            // DELETE button (only for archive, directory might be edited by user)
            if (Path.GetExtension(Path.GetFileName(q.path)) == ".valkyrie")
            {
                ui = new UIElement();
                ui.SetLocation(UIScaler.GetRight(-8.5f), 0.5f, 8, 2);
                ui.SetText(CommonStringKeys.DELETE, Color.grey);
                ui.SetFont(game.gameType.GetHeaderFont());
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetButton(delegate { Delete(q); });
                new UIElementBorder(ui, Color.grey);
            }

            ui = new UIElement();
            ui.SetLocation(0.5f, UIScaler.GetBottom(-2.5f), 8, 2);
            ui.SetText(CommonStringKeys.BACK, Color.red);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(Cancel);
            new UIElementBorder(ui, Color.red);

            ui = new UIElement();
            ui.SetLocation(UIScaler.GetRight(-8.5f), UIScaler.GetBottom(-2.5f), 8, 2);
            ui.SetText(new StringKey("val", "START"), Color.green);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(delegate { Start(q); });
            new UIElementBorder(ui, Color.green);
        }
 /// <summary>
 ///     不显示元素,且不保留空间
 /// </summary>
 /// <param name="element"></param>
 public static void Collapse(this UIElement element) => element.Visibility = Visibility.Collapsed;
 /// <summary>
 ///     不现实元素,但保留空间
 /// </summary>
 /// <param name="element"></param>
 public static void Hide(this UIElement element) => element.Visibility = Visibility.Hidden;
 /// <summary>
 ///     显示元素
 /// </summary>
 /// <param name="element"></param>
 /// <param name="show"></param>
 public static void Show(this UIElement element, bool show) => element.Visibility = show ? Visibility.Visible : Visibility.Collapsed;
예제 #39
0
 public ElementViewModel([NotNull] ParameterViewModel parameterViewModel, [NotNull] UIElement rootElement)
 {
     ParameterViewModel = parameterViewModel;
     RootElement        = rootElement;
 }
예제 #40
0
        void ColumnFilterControl_Loaded(object sender, RoutedEventArgs e)
        {
            DataGridColumn       column    = null;
            DataGridColumnHeader colHeader = null;

            UIElement parent = (UIElement)VisualTreeHelper.GetParent(this);

            while (parent != null)
            {
                parent = (UIElement)VisualTreeHelper.GetParent(parent);
                if (colHeader == null)
                {
                    colHeader = parent as DataGridColumnHeader;
                }

                if (Grid == null)
                {
                    Grid = parent as DataGridExtend;
                }
            }

            if (colHeader != null)
            {
                column = colHeader.Column;
            }

            CanUserFreeze         = Grid.CanUserFreeze;
            CanUserGroup          = Grid.CanUserGroup;
            CanUserSelectDistinct = Grid.CanUserSelectDistinct;

            if (column != null)
            {
                object oCanUserFreeze = column.GetValue(ColumnConfiguration.CanUserFreezeProperty);
                if (oCanUserFreeze != null)
                {
                    CanUserFreeze = (bool)oCanUserFreeze;
                }

                object oCanUserGroup = column.GetValue(ColumnConfiguration.CanUserGroupProperty);
                if (oCanUserGroup != null)
                {
                    CanUserGroup = (bool)oCanUserGroup;
                }

                object oCanUserSelectDistinct = column.GetValue(ColumnConfiguration.CanUserSelectDistinctProperty);
                if (oCanUserSelectDistinct != null)
                {
                    CanUserSelectDistinct = (bool)oCanUserSelectDistinct;
                }
            }
            if (Grid.FilterType == null)
            {
                return;
            }

            FilterColumnInfo = new OptionColumnInfo(column, Grid);

            Grid.RegisterOptionControl(this);

            FilterOperations.Clear();
            if (FilterColumnInfo.PropertyType != null)
            {
                if (TypeHelper.IsNumbericType(FilterColumnInfo.PropertyType) && TypeHelper.IsStringType(FilterColumnInfo.PropertyConvertType))
                {
                    FilterOperations.Add(new FilterOperationItem(Enums.FilterOperation.Equals, "=", "/Jib.WPF.Controls;component/Images/Equal.png"));
                    CalcControlVisibility(ColumnType.ConvertString);
                }
                else
                {
                    if (TypeHelper.IsStringType(FilterColumnInfo.PropertyType) || TypeHelper.IsStringType(FilterColumnInfo.PropertyConvertType))
                    {
                        FilterOperations.Add(new FilterOperationItem(Enums.FilterOperation.Contains, "Contains", "/Jib.WPF.Controls;component/Images/Contains.png"));
                        FilterOperations.Add(new FilterOperationItem(Enums.FilterOperation.StartsWith, "Starts With", "/Jib.WPF.Controls;component/Images/StartsWith.png"));
                        FilterOperations.Add(new FilterOperationItem(Enums.FilterOperation.EndsWith, "Ends With", "/Jib.WPF.Controls;component/Images/EndsWith.png"));
                        CalcControlVisibility(ColumnType.String);
                    }
                    FilterOperations.Add(new FilterOperationItem(Enums.FilterOperation.Equals, "=", "/Jib.WPF.Controls;component/Images/Equal.png"));
                    if (TypeHelper.IsNumbericType(FilterColumnInfo.PropertyType))
                    {
                        FilterOperations.Add(new FilterOperationItem(Enums.FilterOperation.GreaterThan, ">", "/Jib.WPF.Controls;component/Images/GreaterThan.png"));
                        FilterOperations.Add(new FilterOperationItem(Enums.FilterOperation.GreaterThanEqual, ">=", "/Jib.WPF.Controls;component/Images/GreaterThanEqual.png"));
                        FilterOperations.Add(new FilterOperationItem(Enums.FilterOperation.LessThan, "<", "/Jib.WPF.Controls;component/Images/LessThan.png"));
                        FilterOperations.Add(new FilterOperationItem(Enums.FilterOperation.LessThanEqual, "<=", "/Jib.WPF.Controls;component/Images/GreaterThanEqual.png"));
                        FilterOperations.Add(new FilterOperationItem(Enums.FilterOperation.NotEquals, "!=", "/Jib.WPF.Controls;component/Images/NotEqual.png"));
                        CalcControlVisibility(ColumnType.Num);
                    }
                    if (TypeHelper.IsBoolType(FilterColumnInfo.PropertyType) || TypeHelper.IsBoolType(FilterColumnInfo.PropertyConvertType))
                    {
                        CalcControlVisibility(ColumnType.Bool);
                    }
                    if (TypeHelper.IsDateTimeType(FilterColumnInfo.PropertyType))
                    {
                        FilterOperations.Add(new FilterOperationItem(Enums.FilterOperation.GreaterThan, ">", "/Jib.WPF.Controls;component/Images/GreaterThan.png"));
                        FilterOperations.Add(new FilterOperationItem(Enums.FilterOperation.GreaterThanEqual, ">=", "/Jib.WPF.Controls;component/Images/GreaterThanEqual.png"));
                        FilterOperations.Add(new FilterOperationItem(Enums.FilterOperation.LessThan, "<", "/Jib.WPF.Controls;component/Images/LessThan.png"));
                        FilterOperations.Add(new FilterOperationItem(Enums.FilterOperation.LessThanEqual, "<=", "/Jib.WPF.Controls;component/Images/GreaterThanEqual.png"));
                        FilterOperations.Add(new FilterOperationItem(Enums.FilterOperation.NotEquals, "!=", "/Jib.WPF.Controls;component/Images/NotEqual.png"));
                        CalcControlVisibility(ColumnType.Date);
                    }
                }

                if (FilterOperations.Count > 0)
                {
                    SelectedFilterOperation = FilterOperations[0];
                }
            }

            if (FilterColumnInfo != null && FilterColumnInfo.IsValid)
            {
                foreach (var i in DistinctPropertyValues.Where(i => i.IsChecked))
                {
                    i.IsChecked = false;
                }
                DistinctPropertyValues.Clear();
                FilterText = string.Empty;
                _boundColumnPropertyAccessor = null;

                if (!string.IsNullOrWhiteSpace(FilterColumnInfo.PropertyPath))
                {
                    if (FilterColumnInfo.PropertyPath.Contains('.'))
                    {
                        throw new ArgumentException(string.Format("This version of the grid does not support a nested property path such as '{0}'.  Please make a first-level property for filtering and bind to that.", FilterColumnInfo.PropertyPath));
                    }

                    this.Visibility = System.Windows.Visibility.Visible;
                    ParameterExpression arg = System.Linq.Expressions.Expression.Parameter(typeof(object), "x");
                    System.Linq.Expressions.Expression expr = System.Linq.Expressions.Expression.Convert(arg, Grid.FilterType);
                    expr = System.Linq.Expressions.Expression.Property(expr, Grid.FilterType, FilterColumnInfo.PropertyPath);
                    System.Linq.Expressions.Expression conversion = System.Linq.Expressions.Expression.Convert(expr, typeof(object));
                    _boundColumnPropertyAccessor = System.Linq.Expressions.Expression.Lambda <Func <object, object> >(conversion, arg).Compile();

                    if (_boundColumnPropertyAccessor != null)
                    {
                        if (DistinctPropertyValues.Count == 0)
                        {
                            //List<object> result = new List<object>();
                            //foreach (var i in Grid.ItemsSource)
                            //{
                            //    object value = _boundColumnPropertyAccessor(i);
                            //    if (value != null)
                            //    {
                            //        if (result.Where(o => o.ToString() == value.ToString()).Count() == 0)
                            //            result.Add(value);
                            //    }
                            //    else if (FilterColumnInfo.PropertyType == typeof(bool?) && FilterColumnInfo.IsSpecialState)
                            //    {
                            //        if (result.Where(o => o == value).Count() == 0)
                            //            result.Add(value);
                            //    }

                            //}
                            //try
                            //{
                            //    result.Sort();
                            //}
                            //catch
                            //{
                            //    if (System.Diagnostics.Debugger.IsLogging())
                            //        System.Diagnostics.Debugger.Log(0, "Warning", "There is no default compare set for the object type");
                            //}

                            //if (result.Count > 0)
                            //{
                            //    StringBuilder sb = new StringBuilder();
                            //    foreach (var obj in result)
                            //    {
                            //        var item = new CheckboxComboItem()
                            //        {
                            //            Description = GetFormattedValue(obj),
                            //            Tag = obj,
                            //            IsChecked = true
                            //        };
                            //        item.PropertyChanged += new PropertyChangedEventHandler(filter_PropertyChanged);
                            //        DistinctPropertyValues.Add(item);
                            //        sb.AppendFormat("{0}{1}", sb.Length > 0 ? "," : "",item.Description );
                            //    }

                            //    FilterText = sb.ToString();
                            //}
                            //else
                            //{
                            //    FilterText = string.Empty;
                            //}
                        }
                    }
                }
                else
                {
                    this.Visibility = System.Windows.Visibility.Collapsed;
                }
                object oDefaultFilter = column.GetValue(ColumnConfiguration.DefaultFilterProperty);
                if (oDefaultFilter != null)
                {
                    FilterText = (string)oDefaultFilter;
                }
            }
        }
예제 #41
0
 public static bool GetIsSingleClickInCell(UIElement element)
 {
     return((bool)element.GetValue(IsSingleClickInCellProperty));
 }
예제 #42
0
 public void AddElement(UIElement element)
 {
     ElementsToPrint.Add(element);
 }
예제 #43
0
 public static void SetInputBindings(UIElement element, InputBindingCollection inputBindings)
 {
     element.SetValue(InputBindingsProperty, inputBindings);
 }
예제 #44
0
     DependencyProperty.RegisterAttached("IsSingleClickInCell", typeof(bool), typeof(DataGrid), new FrameworkPropertyMetadata(false, OnIsSingleClickInCellSet)); public static void SetIsSingleClickInCell(UIElement element, bool value)
 {
     element.SetValue(IsSingleClickInCellProperty, value);
 }
예제 #45
0
        private static IDisposable InnerCreateLayer(UIElement owner, CALayer parent, LayoutState state)
        {
            var area             = state.Area;
            var background       = state.Background;
            var borderThickness  = state.BorderThickness;
            var borderBrush      = state.BorderBrush;
            var cornerRadius     = state.CornerRadius;
            var backgroundSizing = state.BackgroundSizing;

            var disposables = new CompositeDisposable();
            var sublayers   = new List <CALayer>();

            var heightOffset = ((float)borderThickness.Top / 2) + ((float)borderThickness.Bottom / 2);
            var widthOffset  = ((float)borderThickness.Left / 2) + ((float)borderThickness.Right / 2);
            var halfWidth    = (float)area.Width / 2;
            var halfHeight   = (float)area.Height / 2;
            var adjustedArea = area;

            adjustedArea = adjustedArea.Shrink(
                (nfloat)borderThickness.Left,
                (nfloat)borderThickness.Top,
                (nfloat)borderThickness.Right,
                (nfloat)borderThickness.Bottom
                );

            if (cornerRadius != CornerRadius.None)
            {
                var maxOuterRadius = Math.Max(0, Math.Min(halfWidth - widthOffset, halfHeight - heightOffset));
                var maxInnerRadius = Math.Max(0, Math.Min(halfWidth, halfHeight));

                cornerRadius = new CornerRadius(
                    Math.Min(cornerRadius.TopLeft, maxOuterRadius),
                    Math.Min(cornerRadius.TopRight, maxOuterRadius),
                    Math.Min(cornerRadius.BottomRight, maxOuterRadius),
                    Math.Min(cornerRadius.BottomLeft, maxOuterRadius));

                var innerCornerRadius = new CornerRadius(
                    Math.Min(cornerRadius.TopLeft, maxInnerRadius),
                    Math.Min(cornerRadius.TopRight, maxInnerRadius),
                    Math.Min(cornerRadius.BottomRight, maxInnerRadius),
                    Math.Min(cornerRadius.BottomLeft, maxInnerRadius));

                var outerLayer      = new CAShapeLayer();
                var backgroundLayer = new CAShapeLayer();
                backgroundLayer.FillColor = null;
                outerLayer.FillRule       = CAShapeLayer.FillRuleEvenOdd;
                outerLayer.LineWidth      = 0;


                var path      = GetRoundedRect(cornerRadius, innerCornerRadius, area, adjustedArea);
                var innerPath = GetRoundedPath(cornerRadius, adjustedArea);
                var outerPath = GetRoundedPath(cornerRadius, area);

                var isInnerBorderEdge = backgroundSizing == BackgroundSizing.InnerBorderEdge;
                var backgroundPath    = isInnerBorderEdge ? innerPath : outerPath;
                var backgroundArea    = isInnerBorderEdge ? adjustedArea : area;

                var insertionIndex = 0;

                if (background is GradientBrush gradientBackground)
                {
                    var fillMask = new CAShapeLayer()
                    {
                        Path  = backgroundPath,
                        Frame = area,
                        // We only use the fill color to create the mask area
                        FillColor = _Color.White.CGColor,
                    };

                    CreateGradientBrushLayers(area, backgroundArea, parent, sublayers, ref insertionIndex, gradientBackground, fillMask);
                }
                else if (background is SolidColorBrush scbBackground)
                {
                    Brush.AssignAndObserveBrush(scbBackground, color => backgroundLayer.FillColor = color)
                    .DisposeWith(disposables);
                }
                else if (background is ImageBrush imgBackground)
                {
                    var imgSrc = imgBackground.ImageSource;
                    if (imgSrc != null && imgSrc.TryOpenSync(out var uiImage) && uiImage.Size != CGSize.Empty)
                    {
                        var fillMask = new CAShapeLayer()
                        {
                            Path  = backgroundPath,
                            Frame = area,
                            // We only use the fill color to create the mask area
                            FillColor = _Color.White.CGColor,
                        };

                        CreateImageBrushLayers(area, backgroundArea, parent, sublayers, ref insertionIndex, imgBackground, fillMask);
                    }
                }
                else if (background is AcrylicBrush acrylicBrush)
                {
                    var fillMask = new CAShapeLayer()
                    {
                        Path  = backgroundPath,
                        Frame = area,
                        // We only use the fill color to create the mask area
                        FillColor = _Color.White.CGColor,
                    };

                    acrylicBrush.Subscribe(owner, area, backgroundArea, parent, sublayers, ref insertionIndex, fillMask)
                    .DisposeWith(disposables);
                }
                else if (background is XamlCompositionBrushBase unsupportedCompositionBrush)
                {
                    Brush.AssignAndObserveBrush(unsupportedCompositionBrush, color => backgroundLayer.FillColor = color)
                    .DisposeWith(disposables);
                }
                else
                {
                    backgroundLayer.FillColor = Colors.Transparent;
                }

                outerLayer.Path      = path;
                backgroundLayer.Path = backgroundPath;

                sublayers.Add(outerLayer);
                sublayers.Add(backgroundLayer);
                parent.AddSublayer(outerLayer);
                parent.InsertSublayer(backgroundLayer, insertionIndex);


                if (borderBrush is SolidColorBrush scbBorder || borderBrush == null)
                {
                    Brush.AssignAndObserveBrush(borderBrush, color =>
                    {
                        outerLayer.StrokeColor = color;
                        outerLayer.FillColor   = color;
                    })
                    .DisposeWith(disposables);
                }
                else if (borderBrush is GradientBrush gradientBorder)
                {
                    var fillMask = new CAShapeLayer()
                    {
                        Path  = path,
                        Frame = area,
                        // We only use the fill color to create the mask area
                        FillColor = _Color.White.CGColor,
                    };

                    var borderLayerIndex = parent.Sublayers.Length;
                    CreateGradientBrushLayers(area, area, parent, sublayers, ref borderLayerIndex, gradientBorder, fillMask);
                }

                parent.Mask = new CAShapeLayer()
                {
                    Path  = outerPath,
                    Frame = area,
                    // We only use the fill color to create the mask area
                    FillColor = _Color.White.CGColor,
                };

                if (owner != null)
                {
                    owner.ClippingIsSetByCornerRadius = true;
                }

                state.BoundsPath = outerPath;
            }
예제 #46
0
 public static InputBindingCollection GetInputBindings(UIElement element)
 {
     return((InputBindingCollection)element.GetValue(InputBindingsProperty));
 }
예제 #47
0
 public void CenterAround(UIElement element)
 {
     CenterAround(element, 0, 0);
 }
예제 #48
0
        private static void AddAdorner(UIElement adornedElement, Adorner adorner)
        {
            var layer = AdornerLayer.GetAdornerLayer(adornedElement);

            layer.Add(adorner);
        }
 public GeneralAdorner(UIElement target)
     : base(target)
 {
 }
예제 #50
0
 private void Sticker_ContextRequested(UIElement sender, ContextRequestedEventArgs args)
 {
     ItemContextRequested?.Invoke(sender, args);
 }
예제 #51
0
        private void CopyCodeButton_OnClick(UIMouseEvent evt, UIElement listeningElement)
        {
            int   width  = widthDataProperty.Data;
            int   height = heightDataProperty.Data;
            int   type   = typeDataProperty.Data;
            float speedX = speedXDataProperty.Data;
            float speedY = speedYDataProperty.Data;
            int   alpha  = alphaDataProperty.Data;
            Color color  = useCustomColorCheckbox.Selected ? colorDataProperty.Data : Color.White;
            float scale  = scaleDataProperty.Data;

            StringBuilder s            = new StringBuilder();
            bool          nonOneChance = spawnChanceDataProperty.Data != 1f;

            if (nonOneChance)
            {
                s.Append($"if (Main.rand.NextFloat() < {spawnChanceDataProperty.Data}f)" + Environment.NewLine);
                s.Append($"{{" + Environment.NewLine);
            }
            s.Append($"\tDust dust;" + Environment.NewLine);

            s.Append($"\t// You need to set position depending on what you are doing. You may need to subtract width/2 and height/2 as well to center the spawn rectangle." + Environment.NewLine);
            s.Append($"\tVector2 position = Main.LocalPlayer.Center;" + Environment.NewLine);
            if (NewDustRadioButton.Selected)
            {
                s.Append($"\tdust = Main.dust[Terraria.Dust.NewDust(position, {width}, {height}, {type}, {speedX}f, {speedY}f, {alpha}, new Color({color.R},{color.G},{color.B}), {scale}f)];" + Environment.NewLine);
            }
            else if (NewDustPerfectRadioButton.Selected)
            {
                s.Append($"\tdust = Terraria.Dust.NewDustPerfect(position, {type}, new Vector2({speedX}f, {speedY}f), {alpha}, new Color({color.R},{color.G},{color.B}), {scale}f);" + Environment.NewLine);
            }
            else
            {
                s.Append($"\tdust = Terraria.Dust.NewDustDirect(position, {width}, {height}, {type}, {speedX}f, {speedY}f, {alpha}, new Color({color.R},{color.G},{color.B}), {scale}f);" + Environment.NewLine);
            }

            if (noGravityCheckbox.Selected)
            {
                s.Append($"\tdust.noGravity = true;" + Environment.NewLine);
            }

            if (noLightCheckbox.Selected)
            {
                s.Append($"\tdust.noLight = true;" + Environment.NewLine);
            }

            if (shaderDataProperty.Data > 0)
            {
                s.Append($"\tdust.shader = GameShaders.Armor.GetSecondaryShader({shaderDataProperty.Data}, Main.LocalPlayer);" + Environment.NewLine);
            }

            if (fadeInDataProperty.Data > 0)
            {
                s.Append($"\tdust.fadeIn = {fadeInDataProperty.Data}f;" + Environment.NewLine);
            }
            if (nonOneChance)
            {
                s.Append($"}}" + Environment.NewLine);
            }

            Platform.Current.Clipboard = s.ToString();

            Main.NewText("Copied Dust spawning code to clipboard");
        }
예제 #52
0
        /// <summary>
        /// When overridden in a derived class, measures the size in layout required for
        /// child elements and determines a size for the System.Windows.FrameworkElement-derived class.
        /// </summary>
        /// <param name="availableSize">The available size that this element can give to child elements.
        /// Infinity can be specified as a value to indicate that the element will size to whatever content is available.</param>
        /// <returns>The size that this element determines it needs during layout, based on its calculations of child element sizes.</returns>
        protected override Size MeasureOverride(Size availableSize)
        {
            double x = 0;

            sizes.Clear();
            Size infinity = new Size(double.PositiveInfinity, double.PositiveInfinity);

            foreach (RibbonContextualTabGroup child in InternalChildren)
            {
                // Calculate width of tab items of the group
                double tabsWidth = 0;
                for (int i = 0; i < child.Items.Count; i++)
                {
                    tabsWidth += child.Items[i].DesiredSize.Width;
                }
                child.Measure(infinity);
                double groupWidth = child.DesiredSize.Width;

                bool tabWasChanged = false;
                if (groupWidth > tabsWidth)
                {
                    // If tab's width is less than group's width we have to stretch tabs
                    double delta = (groupWidth - tabsWidth) / child.Items.Count;
                    for (int i = 0; i < child.Items.Count; i++)
                    {
                        if (child.Items[i].DesiredWidth == 0)
                        {
                            child.Items[i].DesiredWidth = child.Items[i].DesiredSize.Width + delta;
                            child.Items[i].Measure(new Size(child.Items[i].DesiredWidth, child.Items[i].DesiredSize.Height));
                            tabWasChanged = true;
                        }
                    }
                }

                if (tabWasChanged)
                {
                    // If we have changed tabs layout we have
                    // to invalidate down to RibbonTabsContainer
                    Visual visual = child.Items[0] as Visual;
                    while (visual != null)
                    {
                        UIElement uiElement = visual as UIElement;
                        if (uiElement != null)
                        {
                            if (uiElement is RibbonTabsContainer)
                            {
                                uiElement.InvalidateMeasure();
                                break;
                            }

                            uiElement.InvalidateMeasure();
                        }

                        visual = VisualTreeHelper.GetParent(visual) as Visual;
                    }
                    tabsWidth = 0;
                    for (int i = 0; i < child.Items.Count; i++)
                    {
                        tabsWidth += child.Items[i].DesiredSize.Width;
                    }
                }

                // Calc final width and measure the group using it
                double finalWidth = tabsWidth;
                x += finalWidth;
                if (x > availableSize.Width)
                {
                    finalWidth -= x - availableSize.Width;
                    x           = availableSize.Width;
                }
                child.Measure(new Size(Math.Max(0, finalWidth), availableSize.Height));
                sizes.Add(new Size(Math.Max(0, finalWidth), availableSize.Height));
            }
            double height = availableSize.Height;

            if (double.IsPositiveInfinity(height))
            {
                height = 0;
            }
            return(new Size(x, height));
        }
예제 #53
0
 public static void SetAutoHidden(UIElement element, bool value)
 {
     element.SetValue(AutoHiddenProperty, value);
 }
예제 #54
0
 public void AddUIElement(UIElement element)
 {
     _uiElements.Add(element);
 }
예제 #55
0
 public static void SetIsReadOnly(UIElement element, bool value)
 {
     element.SetValue(IsReadOnlyProperty, value);
 }
 public static string GetText(UIElement element)
 {
     return((string)element.GetValue(TextProperty));
 }
예제 #57
0
        public UIVirtualKeyboard(string labelText, string startingText, UIVirtualKeyboard.KeyboardSubmitEvent submitAction, Action cancelAction, int inputMode = 0, bool allowEmpty = false)
        {
            this._keyboardContext              = inputMode;
            this._allowEmpty                   = allowEmpty;
            UIVirtualKeyboard.OffsetDown       = 0;
            this._lastOffsetDown               = 0;
            this._edittingSign                 = this._keyboardContext == 1;
            this._edittingChest                = this._keyboardContext == 2;
            UIVirtualKeyboard._currentInstance = this;
            this._submitAction                 = submitAction;
            this._cancelAction                 = cancelAction;
            this._textureShift                 = TextureManager.Load("Images/UI/VK_Shift");
            this._textureBackspace             = TextureManager.Load("Images/UI/VK_Backspace");
            this.Top.Pixels = (float)this._lastOffsetDown;
            float     num1     = (float)(-5000 * this._edittingSign.ToInt());
            float     maxValue = (float)byte.MaxValue;
            float     num2     = 0.0f;
            float     num3     = 516f;
            UIElement element  = new UIElement();

            element.Width.Pixels  = (float)((double)num3 + 8.0 + 16.0);
            element.Top.Precent   = num2;
            element.Top.Pixels    = maxValue;
            element.Height.Pixels = 266f;
            element.HAlign        = 0.5f;
            element.SetPadding(0.0f);
            this.outerLayer1 = element;
            UIElement uiElement = new UIElement();

            uiElement.Width.Pixels  = (float)((double)num3 + 8.0 + 16.0);
            uiElement.Top.Precent   = num2;
            uiElement.Top.Pixels    = maxValue;
            uiElement.Height.Pixels = 266f;
            uiElement.HAlign        = 0.5f;
            uiElement.SetPadding(0.0f);
            this.outerLayer2 = uiElement;
            UIPanel mainPanel = new UIPanel();

            mainPanel.Width.Precent   = 1f;
            mainPanel.Height.Pixels   = 225f;
            mainPanel.BackgroundColor = new Color(23, 33, 69) * 0.7f;
            element.Append((UIElement)mainPanel);
            float num4 = -79f;

            this._textBox = new UITextBox("", 0.78f, true);
            this._textBox.BackgroundColor = Color.Transparent;
            this._textBox.BorderColor     = Color.Transparent;
            this._textBox.HAlign          = 0.5f;
            this._textBox.Width.Pixels    = num3;
            this._textBox.Top.Pixels      = (float)((double)num4 + (double)maxValue - 10.0) + num1;
            this._textBox.Top.Precent     = num2;
            this._textBox.Height.Pixels   = 37f;
            this.Append((UIElement)this._textBox);
            for (int x = 0; x < 10; ++x)
            {
                for (int y = 0; y < 4; ++y)
                {
                    UITextPanel <object> keyboardButton = this.CreateKeyboardButton((object)"1234567890qwertyuiopasdfghjkl'zxcvbnm,.?"[y * 10 + x].ToString(), x, y, 1, true);
                    keyboardButton.OnClick += new UIElement.MouseEvent(this.TypeText);
                    mainPanel.Append((UIElement)keyboardButton);
                }
            }
            this._shiftButton                 = this.CreateKeyboardButton((object)"", 0, 4, 1, false);
            this._shiftButton.PaddingLeft     = 0.0f;
            this._shiftButton.PaddingRight    = 0.0f;
            this._shiftButton.PaddingBottom   = this._shiftButton.PaddingTop = 0.0f;
            this._shiftButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
            this._shiftButton.BorderColor     = this._internalBorderColor * 0.7f;
            this._shiftButton.OnMouseOver    += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                this._shiftButton.BorderColor = this._internalBorderColorSelected;
                if (this._keyState == UIVirtualKeyboard.KeyState.Shift)
                {
                    return;
                }
                this._shiftButton.BackgroundColor = new Color(73, 94, 171);
            });
            this._shiftButton.OnMouseOut += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                this._shiftButton.BorderColor = this._internalBorderColor * 0.7f;
                if (this._keyState == UIVirtualKeyboard.KeyState.Shift)
                {
                    return;
                }
                this._shiftButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
            });
            this._shiftButton.OnClick += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                Main.PlaySound(12, -1, -1, 1, 1f, 0.0f);
                this.SetKeyState(this._keyState == UIVirtualKeyboard.KeyState.Shift ? UIVirtualKeyboard.KeyState.Default : UIVirtualKeyboard.KeyState.Shift);
            });
            UIImage uiImage1 = new UIImage(this._textureShift);

            uiImage1.HAlign     = 0.5f;
            uiImage1.VAlign     = 0.5f;
            uiImage1.ImageScale = 0.85f;
            this._shiftButton.Append((UIElement)uiImage1);
            mainPanel.Append((UIElement)this._shiftButton);
            this._symbolButton                 = this.CreateKeyboardButton((object)"@%", 1, 4, 1, false);
            this._symbolButton.PaddingLeft     = 0.0f;
            this._symbolButton.PaddingRight    = 0.0f;
            this._symbolButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
            this._symbolButton.BorderColor     = this._internalBorderColor * 0.7f;
            this._symbolButton.OnMouseOver    += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                this._symbolButton.BorderColor = this._internalBorderColorSelected;
                if (this._keyState == UIVirtualKeyboard.KeyState.Symbol)
                {
                    return;
                }
                this._symbolButton.BackgroundColor = new Color(73, 94, 171);
            });
            this._symbolButton.OnMouseOut += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                this._symbolButton.BorderColor = this._internalBorderColor * 0.7f;
                if (this._keyState == UIVirtualKeyboard.KeyState.Symbol)
                {
                    return;
                }
                this._symbolButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
            });
            this._symbolButton.OnClick += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                Main.PlaySound(12, -1, -1, 1, 1f, 0.0f);
                this.SetKeyState(this._keyState == UIVirtualKeyboard.KeyState.Symbol ? UIVirtualKeyboard.KeyState.Default : UIVirtualKeyboard.KeyState.Symbol);
            });
            mainPanel.Append((UIElement)this._symbolButton);
            this.BuildSpaceBarArea(mainPanel);
            this._submitButton = new UITextPanel <LocalizedText>(this._edittingSign || this._edittingChest ? Language.GetText("UI.Save") : Language.GetText("UI.Submit"), 0.4f, true);
            this._submitButton.Height.Pixels = 37f;
            this._submitButton.Width.Precent = 0.4f;
            this._submitButton.HAlign        = 1f;
            this._submitButton.VAlign        = 1f;
            this._submitButton.PaddingLeft   = 0.0f;
            this._submitButton.PaddingRight  = 0.0f;
            this.ValidateText();
            this._submitButton.OnMouseOver += (UIElement.MouseEvent)((evt, listeningElement) => this.ValidateText());
            this._submitButton.OnMouseOut  += (UIElement.MouseEvent)((evt, listeningElement) => this.ValidateText());
            this._submitButton.OnClick     += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                string text = this.Text.Trim();
                if (text.Length <= 0 && !this._edittingSign && (!this._edittingChest && !this._allowEmpty))
                {
                    return;
                }
                Main.PlaySound(10, -1, -1, 1, 1f, 0.0f);
                this._submitAction(text);
            });
            element.Append((UIElement)this._submitButton);
            this._cancelButton = new UITextPanel <LocalizedText>(Language.GetText("UI.Cancel"), 0.4f, true);
            this.StyleKey <LocalizedText>(this._cancelButton, true);
            this._cancelButton.Height.Pixels = 37f;
            this._cancelButton.Width.Precent = 0.4f;
            this._cancelButton.VAlign        = 1f;
            this._cancelButton.OnClick      += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                Main.PlaySound(11, -1, -1, 1, 1f, 0.0f);
                this._cancelAction();
            });
            element.Append((UIElement)this._cancelButton);
            this._submitButton2               = new UITextPanel <LocalizedText>(this._edittingSign || this._edittingChest ? Language.GetText("UI.Save") : Language.GetText("UI.Submit"), 0.72f, true);
            this._submitButton2.TextColor     = Color.Silver;
            this._submitButton2.DrawPanel     = false;
            this._submitButton2.Height.Pixels = 60f;
            this._submitButton2.Width.Precent = 0.4f;
            this._submitButton2.HAlign        = 0.5f;
            this._submitButton2.VAlign        = 0.0f;
            this._submitButton2.OnMouseOver  += (UIElement.MouseEvent)((a, b) =>
            {
                ((UITextPanel <LocalizedText>)b).TextScale = 0.85f;
                ((UITextPanel <LocalizedText>)b).TextColor = Color.White;
            });
            this._submitButton2.OnMouseOut += (UIElement.MouseEvent)((a, b) =>
            {
                ((UITextPanel <LocalizedText>)b).TextScale = 0.72f;
                ((UITextPanel <LocalizedText>)b).TextColor = Color.Silver;
            });
            this._submitButton2.Top.Pixels   = 50f;
            this._submitButton2.PaddingLeft  = 0.0f;
            this._submitButton2.PaddingRight = 0.0f;
            this.ValidateText();
            this._submitButton2.OnMouseOver += (UIElement.MouseEvent)((evt, listeningElement) => this.ValidateText());
            this._submitButton2.OnMouseOut  += (UIElement.MouseEvent)((evt, listeningElement) => this.ValidateText());
            this._submitButton2.OnClick     += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                string text = this.Text.Trim();
                if (text.Length <= 0 && !this._edittingSign && (!this._edittingChest && !this._allowEmpty))
                {
                    return;
                }
                Main.PlaySound(10, -1, -1, 1, 1f, 0.0f);
                this._submitAction(text);
            });
            this.outerLayer2.Append((UIElement)this._submitButton2);
            this._cancelButton2              = new UITextPanel <LocalizedText>(Language.GetText("UI.Cancel"), 0.72f, true);
            this._cancelButton2.TextColor    = Color.Silver;
            this._cancelButton2.DrawPanel    = false;
            this._cancelButton2.OnMouseOver += (UIElement.MouseEvent)((a, b) =>
            {
                ((UITextPanel <LocalizedText>)b).TextScale = 0.85f;
                ((UITextPanel <LocalizedText>)b).TextColor = Color.White;
            });
            this._cancelButton2.OnMouseOut += (UIElement.MouseEvent)((a, b) =>
            {
                ((UITextPanel <LocalizedText>)b).TextScale = 0.72f;
                ((UITextPanel <LocalizedText>)b).TextColor = Color.Silver;
            });
            this._cancelButton2.Height.Pixels = 60f;
            this._cancelButton2.Width.Precent = 0.4f;
            this._cancelButton2.Top.Pixels    = 114f;
            this._cancelButton2.VAlign        = 0.0f;
            this._cancelButton2.HAlign        = 0.5f;
            this._cancelButton2.OnClick      += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                Main.PlaySound(11, -1, -1, 1, 1f, 0.0f);
                this._cancelAction();
            });
            this.outerLayer2.Append((UIElement)this._cancelButton2);
            UITextPanel <object> keyboardButton1 = this.CreateKeyboardButton((object)"", 8, 4, 2, true);

            keyboardButton1.OnClick += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                Main.PlaySound(12, -1, -1, 1, 1f, 0.0f);
                this._textBox.Backspace();
                this.ValidateText();
            });
            keyboardButton1.PaddingLeft   = 0.0f;
            keyboardButton1.PaddingRight  = 0.0f;
            keyboardButton1.PaddingBottom = keyboardButton1.PaddingTop = 0.0f;
            UIImage uiImage2 = new UIImage(this._textureBackspace);

            uiImage2.HAlign     = 0.5f;
            uiImage2.VAlign     = 0.5f;
            uiImage2.ImageScale = 0.92f;
            keyboardButton1.Append((UIElement)uiImage2);
            mainPanel.Append((UIElement)keyboardButton1);
            UIText uiText = new UIText(labelText, 0.75f, true);

            uiText.HAlign        = 0.5f;
            uiText.Width.Pixels  = num3;
            uiText.Top.Pixels    = (float)((double)num4 - 37.0 - 4.0) + maxValue + num1;
            uiText.Top.Precent   = num2;
            uiText.Height.Pixels = 37f;
            this.Append((UIElement)uiText);
            this._label = uiText;
            this.Append(element);
            this._textBox.SetTextMaxLength(this._edittingSign ? 99999 : 20);
            this.Text = startingText;
            if (this.Text.Length == 0)
            {
                this.SetKeyState(UIVirtualKeyboard.KeyState.Shift);
            }
            UIVirtualKeyboard.OffsetDown = 9999;
            this.UpdateOffsetDown();
        }
예제 #58
0
 public static bool GetIsReadOnly(UIElement element)
 {
     return((bool)element.GetValue(IsReadOnlyProperty));
 }
예제 #59
0
 void m_Slider_OnChange(UIElement element)
 {
     ScrollOffset = (int)m_Slider.Value;
 }
예제 #60
0
 public static bool GetAutoHidden(UIElement element)
 {
     return((bool)element.GetValue(AutoHiddenProperty));
 }