Inheritance: FrameworkElement, IControl, IControlOverrides, IControlProtected
Ejemplo n.º 1
0
		public static void SwitchVisibility ( bool v , Control control )
		{
			if ( v )
				control.Visibility = Windows.UI.Xaml.Visibility.Visible;
			else
				control.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
		}
        private static void TrySetText(Control element, string text)
        {
            // TODO Research why TextBox does not support IValueProvider
            var provider = element.GetProviderOrDefault<IValueProvider>(PatternInterface.Value);

            if (provider != null)
            {
                provider.SetValue(text);
            }
            else if (element is TextBox)
            {
                var textBox = element as TextBox;
                textBox.Text = text;
                textBox.SelectionStart = text.Length;
            }
            else if (element is PasswordBox)
            {
                var passwordBox = element as PasswordBox;
                passwordBox.Password = text;
            }
            else
            {
                throw new AutomationException("Element does not support SendKeys.", ResponseStatus.UnknownError);
            }

            // TODO: new parameter - FocusState
            element.Focus(FocusState.Pointer);
        }
 // When the user engages the control, put initial focus on the first item.
 void OnFocusEngaged(Control sender, FocusEngagedEventArgs e)
 {
     if (IsGamepadSupported)
     {
         InitialButton.Focus(FocusState.Programmatic);
     }
 }
Ejemplo n.º 4
0
        public void Reset(Control host)
        {
            H1.Reset(host);
            H2.Reset(host);
            H3.Reset(host);
            H4.Reset(host);
            H5.Reset(host);
            H6.Reset(host);
            BlockQuote.Reset(host);
            P.Reset(host);
            FigCaption.Reset(host);
            Pre.Reset(host);
            Dt.Reset(host);
            Dd.Reset(host);

            Li.Reset(host);

            A.Reset(host);
            Span.Reset(host);
            Label.Reset(host);
            Q.Reset(host);
            Cite.Reset(host);
            I.Reset(host);
            Em.Reset(host);
            Mark.Reset(host);
            Time.Reset(host);
            Code.Reset(host);
            Strong.Reset(host);
        }
Ejemplo n.º 5
0
        public static bool IntersectsWith(this Control first, Control second)
        {
            Rect p1 = first.Position();
            Rect p2 = second.Position();

            return (p1.Y + p1.Height < p2.Y) || (p1.Y > p2.Y + p2.Height) || (p1.X + p1.Width < p2.X) || (p1.X > p2.X + p2.Width);
        }
 private void LoseFocus(Control control)
 {
     var isTabStop = control.IsTabStop;
     control.IsTabStop = false;
     control.IsEnabled = false;
     control.IsEnabled = true;
     control.IsTabStop = isTabStop;
 }
Ejemplo n.º 7
0
 private void btnHome_Click(object sender, RoutedEventArgs e)
 {
     if(_currentUser != _ucMyHome)
     {
         _currentUser = _ucMyHome;
         gridMain.Children.RemoveAt(1);
         gridMain.Children.Add(_ucMyHome);
     }
 }
Ejemplo n.º 8
0
 public static void BindProperty(Control control, object source, string path,
     DependencyProperty property, BindingMode mode)
 {
     var binding = new Binding();
     binding.Path = new PropertyPath(path);
     binding.Source = source;
     binding.Mode = mode;
     control.SetBinding(property, binding);
 }
Ejemplo n.º 9
0
 private void btnSupport_Click(object sender, RoutedEventArgs e)
 {
     if (_currentUser != _ucSupport)
     {
         _currentUser = _ucSupport;
         gridMain.Children.RemoveAt(1);
         gridMain.Children.Add(_ucSupport);
     }
 }
 protected override bool GoToStateCore(Windows.UI.Xaml.Controls.Control control, FrameworkElement templateRoot, string stateName, VisualStateGroup group, VisualState state, bool useTransitions)
 {
     //replace OpenUp state change with OpenDown one and continue as normal
     if (!string.IsNullOrWhiteSpace(stateName) && stateName.EndsWith("OpenUp"))
     {
         stateName = stateName.Substring(0, stateName.Length - 6) + "OpenDown";
     }
     return(base.GoToStateCore(control, templateRoot, stateName, group, state, useTransitions));
 }
Ejemplo n.º 11
0
 public async void Initialize(Windows.Storage.IStorageFile value, Control target = null)
 {
     var book = await Books.BookManager.GetBookFromFile(value);
     if (book != null && book is Books.IBookFixed)
     {
         Initialize(book as Books.IBookFixed, target);
         this.Title = System.IO.Path.GetFileNameWithoutExtension(value.Name);
     }
 }
Ejemplo n.º 12
0
 private void btnSetting_Click(object sender, RoutedEventArgs e)
 {
     if (_currentUser != _ucSettings)
     {
         gridMain.Children.RemoveAt(1);
         _currentUser = _ucSettings;
         gridMain.Children.Add(_ucSettings);
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of the InteractionHelper class.
        /// </summary>
        /// <param name="control">Control receiving interaction.</param>
        public InteractionHelper(Control control)
        {
            Debug.Assert(control != null, "control should not be null!");
            Control = control;
            _updateVisualState = control as IUpdateVisualState;

            // Wire up the event handlers for events without a virtual override
            control.Loaded += OnLoaded;
            control.IsEnabledChanged += OnIsEnabledChanged;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Returns the trigger collection for a particular control.
        /// </summary>
        public static TriggerCollection GetTriggers(Control control)
        {
            TriggerCollection collection;
            if (!instance.triggerLookup.TryGetValue(control, out collection))
            {
                collection = new TriggerCollection(control);
                instance.triggerLookup[control] = collection;
                control.Unloaded += OnControlUnloaded;
            }

            return collection;
        }
        protected override bool GoToStateCore(Control control, FrameworkElement stateGroupsRoot, string stateName, VisualStateGroup group, VisualState state, bool useTransitions)
        {
            if ((group == null) || (state == null))
            {
                return false;
            }

            if (control == null)
            {
                control = new ContentControl();
            }

            return base.GoToStateCore(control, stateGroupsRoot, stateName, group, state, useTransitions);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Transitions the control between two states.
        /// </summary>
        /// <param name="control">The <see cref="Windows.UI.Xaml.Controls.Control"/> to transition between states.</param>
        /// <param name="stateName">The state to transition to.</param>
        /// <param name="useTransitions">True to use a <see cref="Windows.UI.Xaml.VisualTransition"/> to transition between states; otherwise, false.</param>
        /// <returns>True if the <paramref name="control"/> is successfully transitioned to the new state; otherwise, false.</returns>
        /// <exception cref="System.ArgumentNullException"><paramref name="control"/> or <paramref name="stateName"/> is null.</exception>
        public static bool GoToState(Control control, string stateName, bool useTransitions)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }

            if (string.IsNullOrEmpty(stateName))
            {
                throw new ArgumentNullException("stateName");
            }

            control.ApplyTemplate();
            return VisualStateManager.GoToState(control, stateName, useTransitions);
        }
Ejemplo n.º 17
0
 public MainPage()
 {
     this.InitializeComponent();
     _ucMyHome = new ucMyHome();
     _ucMyHome.ViewRoomClicked += _ucMyHome_NewRoomClicked;
     _ucMyRoom = new ucMyRoom();
     _ucMyRoom.HomeBack += _ucMyRoom_HomeBack;
     _ucSettings = new ucSettings();
     _ucSupport = new ucSupport();
     _currentUser = _ucMyHome;
     gridMain.Children.Add(_ucMyHome);
     Grid.SetRow(_ucMyHome, 1);
     Grid.SetRow(_ucMyRoom, 1);
     Grid.SetRow(_ucSettings, 1);
     Grid.SetRow(_ucSupport, 1);
 }
Ejemplo n.º 18
0
        public async void Initialize(Books.IBookFixed value, Control target=null)
        {
            if (BookInfo != null) SaveInfo();
            this.Title = "";

            var pages = new ObservableCollection<PageViewModel>();
            var option = OptionCache = target == null ? OptionCache : new Books.PageOptionsControl(target);
            for (uint i = 0; i < value.PageCount; i++)
            {
                uint page = i;
                pages.Add(new PageViewModel(new Books.VirtualPage(() => { var p = value.GetPage(page); p.Option = option; return p; })));
            }
            this._Reversed = false;
            this._PageSelected = 0;
            ID = value.ID;
            this.Pages = pages;
            BookInfo = await BookInfoStorage.GetBookInfoByIDOrCreateAsync(value.ID);
            var tempPageSelected = (bool)SettingStorage.GetValue("SaveLastReadPage") ? (int)(BookInfo?.GetLastReadPage()?.Page ?? 1):1;
            this.PageSelected = tempPageSelected == this.PagesCount ? 1 : tempPageSelected;
            this.Reversed = BookInfo?.PageReversed ?? false;
            OnPropertyChanged(nameof(Reversed));
            this.AsBookShelfBook = null;

            this.Bookmarks = new ObservableCollection<BookmarkViewModel>();
            {
                var rl = new Windows.ApplicationModel.Resources.ResourceLoader();
                var bm = new BookmarkViewModel() { Page = 1, AutoGenerated = true, Title = rl.GetString("BookmarkTop/Title") };
                this.Bookmarks.Add(bm);
            }
            foreach (var bm in BookInfo.Bookmarks)
            {
                this.Bookmarks.Add(new BookmarkViewModel(bm) );
            }
            {
                var rl = new Windows.ApplicationModel.Resources.ResourceLoader();
                var bm = new BookmarkViewModel() { Page = this.PagesCount, AutoGenerated = true, Title = rl.GetString("BookmarkLast/Title") };
                this.Bookmarks.Add(bm);
            }
        }
        public BasicFlyout(Control view)
        {
            // create a popup...
            this.Popup = new Popup();

            // indicate that we can dismiss it implicitly...
            this.Popup.IsLightDismissEnabled = true;

            // put the view on it...
            this.Popup.Child = view;

            // set the width - this will redo the layout...
            this.Width = BasicFlyoutWidth.Narrow;

            // subscribe to handle system dismiss...
            var window = Window.Current;
            window.Activated += window_Activated;
            this.Popup.Closed += Popup_Closed;

            // bind dismiss?
            if (this.ViewModel is IDismissCommand)
                ((IDismissCommand)this.ViewModel).DismissCommand = new DelegateCommand((args) => this.Hide());
        }
 private void btnAdd_Loaded(object sender, RoutedEventArgs e)
 {
     btnAdd = sender as Control;
     SetBtnAddAvailability();
 }
Ejemplo n.º 21
0
    public PageOptionsControl(Windows.UI.Xaml.Controls.Control control)
    {
        this._TargetControl = control;

        control.SizeChanged += Control_SizeChanged;
    }
Ejemplo n.º 22
0
 private void SetCurrentViewState(Control viewStateAwareControl)
 {
     VisualStateManager.GoToState(viewStateAwareControl, this.GetViewState(), false);
 }
Ejemplo n.º 23
0
 private static bool HasDefaultValue(Control control, DependencyProperty property)
 {
     Debug.Assert(control != null, "control should not be null!");
     Debug.Assert(property != null, "property should not be null!");
     return control != null && control.ReadLocalValue(property) == DependencyProperty.UnsetValue;
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Use VisualStateManager to change the visual state of the control.
        /// </summary>
        /// <param name="control">
        /// Control whose visual state is being changed.
        /// </param>
        /// <param name="useTransitions">
        /// A value indicating whether to use transitions when updating the
        /// visual state, or to snap directly to the new visual state.
        /// </param>
        /// <param name="stateNames">
        /// Ordered list of state names and fallback states to transition into.
        /// Only the first state to be found will be used.
        /// </param>
        public static void GoToState(Control control, bool useTransitions, params string[] stateNames)
        {
            Debug.Assert(control != null, "control should not be null!");
            Debug.Assert(stateNames != null, "stateNames should not be null!");
            Debug.Assert(stateNames.Length > 0, "stateNames should not be empty!");

            foreach (string name in stateNames)
            {
                if (VisualStateManager.GoToState(control, name, useTransitions))
                {
                    break;
                }
            }
        }
Ejemplo n.º 25
0
 public void Attach(Control c)
 {
     this.control = c;
     this.control.PointerEntered += OnPointerEntered;
     this.control.PointerExited += OnPointerExited;
     this.control.Unloaded += OnControlUnloaded;
 }
Ejemplo n.º 26
0
 public void RemoveCornerEvents(Control corner)
 {
     corner.PointerPressed -= Corner_PointerPressed;
     corner.PointerMoved -= Corner_PointerMoved;
     corner.PointerReleased -= Corner_PointerReleased;
 }
Ejemplo n.º 27
0
 public void AddCornerEvents(Control corner)
 {
     corner.PointerPressed += Corner_PointerPressed;
     corner.PointerMoved += Corner_PointerMoved;
     corner.PointerReleased += Corner_PointerReleased;
 }
        private async Task DoUpdate(string property, JToken input, Control inputBox, TextBlock errorBlock, UIElement progress) {
            errorBlock.Text = "";
            progress.Visibility = Visibility.Visible;
            inputBox.BorderBrush = new SolidColorBrush(Color.FromArgb(0xA3, 0, 0, 0));

            try {
                var response = await session.UpdateProperty<Session>(true, property.KeyOf(input));
                if (response.Flash != null) {
                    var nameError = response.Errors.FirstOrDefault(error => error.Node == property);
                    SetError(inputBox, errorBlock, nameError != null ? nameError.Message : response.Flash.Message);
                }
            } catch {
                SetError(inputBox, errorBlock, "An error occured");
            }

            progress.Visibility = Visibility.Collapsed;
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Prepares an instance of the DateTimeAxisLabel class by setting its
        /// IntervalType property.
        /// </summary>
        /// <param name="label">An instance of the DateTimeAxisLabel class.
        /// </param>
        /// <param name="dataContext">The data context to assign to the label.
        /// </param>
        protected override void PrepareAxisLabel(Control label, object dataContext)
        {
            DateTimeAxisLabel dateTimeAxisLabel = label as DateTimeAxisLabel;

            if (dateTimeAxisLabel != null)
            {
                dateTimeAxisLabel.IntervalType = ActualIntervalType;
            }
            base.PrepareAxisLabel(label, dataContext);
        }
Ejemplo n.º 30
0
 public InkEventArgs(PointerPoint point, Control container)
 {
     this.Position = new Vector2((float) (point.Position.X / container.ActualWidth), (float) (point.Position.Y / container.ActualHeight));
     if (point.PointerDevice.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Pen) {
         this.Pressure = point.Properties.Pressure;
     } else {
         this.Pressure = null;
     }
 }
Ejemplo n.º 31
0
 public InkButtonEventArgs(ButtonType button, ButtonStatus buttonStatus, PointerPoint point, Control container)
     : base(point, container)
 {
     this.ButtonStatus = buttonStatus;
     this.Button = button;
 }
 private void SetError(Control inputBox, TextBlock errorBlock, string message) {
     errorBlock.Text = message;
     inputBox.BorderBrush = new SolidColorBrush(Colors.Red);
 }