private void Button_Click(object sender, RoutedEventArgs e)
 {
     this.Selected = !this.Selected;
     VisualStateManager.GoToElementState(this.root, this.Selected ? "SelectedSate" : "NotSelectedState", true);
     HistoryViewCommands.SelectCommit.Execute(this.txtId.Text, null);
     e.Handled = true;
 }
Example #2
0
 public static void GoElementState(this FrameworkElement fe, params string[] stateNames)
 {
     foreach (var stateName in stateNames)
     {
         VisualStateManager.GoToElementState(fe, stateName, true);
     }
 }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code
        /// or internal processes call System.Windows.FrameworkElement.ApplyTemplate().
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.PartBorder = (Border)this.GetTemplateChild("PartBorder");

            if (this.PartBorder != null)
            {
                VisualStateManager.GoToElementState(this.PartBorder, this.IsActive ? "Active" : "Inactive", false);
                foreach (VisualStateGroup group in VisualStateManager.GetVisualStateGroups(this.PartBorder))
                {
                    if (group.Name == "ActiveStates")
                    {
                        foreach (VisualState state in group.States)
                        {
                            if (state.Name == "Active")
                            {
                                state.Storyboard.SetSpeedRatio(this.PartBorder, this.SpeedRatio);
                            }
                        }
                    }
                }

                this.PartBorder.Visibility = this.IsActive ? Visibility.Visible : Visibility.Collapsed;
            }
        }
Example #4
0
        /// <summary>
        /// Overlay the full screen view of the image
        /// </summary>
        private void OnShowOverlayGrid(object sender, RoutedEventArgs e)
        {
            GameScreenViewModel viewModel = this.DataContext as GameScreenViewModel;

            if (viewModel.CurrentGame == "OddOneOut")
            {
                VisualStateManager.GoToElementState(OddOneOutGrid, OddOneOutNormalState, false);
                VisualStateManager.GoToElementState(OddOneOutGrid, OddOneOutFadeInState, false);
                OddOneOutGB.Start(viewModel.CurrentPage.KinectGame as OddOneOutGame, OnCloseOverlayGrid);
            }

            if (viewModel.CurrentGame == "SimonSaysGame")
            {
                VisualStateManager.GoToElementState(SimonSaysGrid, NormalState, false);
                VisualStateManager.GoToElementState(SimonSaysGrid, FadeInTransitionState, false);
                SimonSaysBoard.Start(viewModel.CurrentPage.KinectGame as SimonSaysGame, OnCloseOverlayGrid);
            }

            if (this.CurrentGame == "VirtualDrumKit")
            {
                VisualStateManager.GoToElementState(SimonSaysGrid, VirtualDrumKitNormalState, false);
                VisualStateManager.GoToElementState(SimonSaysGrid, VirtualDrumKitFadeInState, false);
            }

            if (this.CurrentGame == "NoGoNo")
            {
                VisualStateManager.GoToElementState(SimonSaysGrid, NoGoNoNormalState, false);
                VisualStateManager.GoToElementState(SimonSaysGrid, NoGoNoFadeInState, false);
            }

            // Always go to normal state before a transition
            //  this.SelectedImage = ((ContentControl)e.OriginalSource).Content as ImageSource;
            //VisualStateManager.GoToElementState(SimonSaysGrid, NormalState, false);
            //VisualStateManager.GoToElementState(SimonSaysGrid, FadeInTransitionState, false);
        }
        private void UpdateVisualState()
        {
            if (page == null)
            {
                return;
            }
            RunActionsButtonVisibility = Visibility.Collapsed;

            if (ContainerState == Core.Action.Types.ActionInvokeStateType.Runing || ContainerState == Core.Action.Types.ActionInvokeStateType.Busy)
            {
                VisualStateManager.GoToElementState(page, "ActionsRuning", true);
            }
            else if (IsActionsTabItemSelected)
            {
                VisualStateManager.GoToElementState(page, "ActionsTabSelected", true);
                RunActionsButtonVisibility = Visibility.Visible;
            }
            else if (IsInfoTabItemSelected)
            {
                VisualStateManager.GoToElementState(page, "InfoTabSelected", true);
            }
            else if (IsEventTabItemSelected)
            {
                VisualStateManager.GoToElementState(page, "EventTabSelected", true);
            }
            else if (IsConditionTabItemSelected)
            {
                VisualStateManager.GoToElementState(page, "ConditionTabSelected", true);
            }
            else
            {
                VisualStateManager.GoToElementState(page, "NoTabSelected", true);
            }
        }
        public void Close()
        {
            _quickProcessingWindow.Close();

            //enable user interaction
            VisualStateManager.GoToElementState(_disableElement, "Ready", true);
        }
Example #7
0
        private void Knob_OnMouseUp(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                ((UIElement)sender).ReleaseMouseCapture();

                if (_isMouseOn)
                {
                    VisualStateManager.GoToElementState(this, (!IsRealValueTrue()) ? "MouseOverOff" : "MouseOverOn", true);
                }
                else
                {
                    VisualStateManager.GoToElementState(this, (!IsRealValueTrue()) ? "NormalOff" : "NormalOn", true);
                }

                if (_isMouseOn)
                {
                    _value = 1 - GetRealValue();

                    if (_parameter != null)
                    {
                        _parameter.BeginEditValueFromUI();
                        SetValue();
                        _parameter.FinishEditValueFromUI();

                        PluginUI.Instance.Log(string.Format("{0} = {1} {2}", _parameter.Name, _parameter.GetDisplayValue(), _parameter.Label));
                    }
                    else
                    {
                        UpdateController();
                    }
                }
            }
        }
Example #8
0
        public TitleScreen()
        {
            this.InitializeComponent();
            //this.RotatingRing.Children.Add(new RotatingRing());

            VisualStateManager.GoToElementState(this.LayoutRoot, "StartAnimation", true);
        }
        private async void StartStreamer_Click(object sender, RoutedEventArgs e)
        {
            if (Properties.Settings.Default.IsStartOBS)
            {
                if (ProjectData.Default.IsObsRunning)
                {
                    MessageBox.Show("OBS is running, please close it first", "Sorry!", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }
            }

            this.IsEnabled = false;

            VisualStateManager.GoToElementState(this.Content as Grid, "NginxStarting", false);
            VisualStateManager.GoToElementState(this.Content as Grid, "QSVStarting", false);
            VisualStateManager.GoToElementState(this.Content as Grid, "FFMpegStarting", false);

            try
            {
                await ProjectData.Default.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Oops!", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            this.IsEnabled = true;

            tmr.Start();
        }
Example #10
0
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="txt">The text.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        internal void Search(string txt)
        {
            if (String.IsNullOrEmpty(txt))
            {
                VisualStateManager.GoToElementState(this.Content as FrameworkElement, "ChooseState", true);
                isSearchMode = false;
                SetCurrent(null);
                return;
            }
            else
            {
                VisualStateManager.GoToElementState(this.Content as FrameworkElement, "SearchState", true);
                isSearchMode = true;
            }

            IsBusy = true;
            Action action = new Action(() =>
            {
                Dispatcher.Invoke(new Action(() =>
                {
                    CityData.SearchResult        = Agent.SearchCity(txt);
                    searchDataGrid.SelectedIndex = 0;
                    searchDataGrid.Focus();
                }));
            });

            AsynHelper.Invoke(action, (ex) =>
            {
                Logger.WriteLog(LogType.ERROR, ex.Message, ex);
            }).ContinueWith((task) =>
            {
                InvokeSetBusy(false);
            });
        }
Example #11
0
        public DownloadUpdatesView()
        {
            InitializeComponent();

            this.WhenAny(x => x.ViewModel.State, x => x.Value)
            .Where(x => x != null)
            .Subscribe(x => VisualStateManager.GoToElementState(Grid, x, true));

            this.BindCommand(ViewModel,
                             vm => vm.Download,
                             view => view.DownloadUpdates);

            this.Bind(ViewModel,
                      vm => vm.Progress,
                      view => view.CheckingProgress.Value);

            this.Bind(ViewModel,
                      vm => vm.UpdateCount,
                      view => view.UpdatesCount.Text);

            this.Bind(ViewModel,
                      vm => vm.LatestVersion,
                      view => view.LatestVersion.Text);

            this.Bind(ViewModel,
                      vm => vm.UpdateSize,
                      view => view.UpdatesSize.Text);
        }
Example #12
0
        void SetVisualState()
        {
            var layout    = AppSettings.Instance.Prediction.PredictionLayout;
            var stateName = layout.ToString();

            VisualStateManager.GoToElementState(ThePanel, stateName, false);
        }
Example #13
0
 protected override void OnChecked(RoutedEventArgs e)
 {
     base.OnChecked(e);
     bg.SetResourceReference(BackgroundProperty, "CheckedDate");
     dateNumber.IsActive = true;
     VisualStateManager.GoToElementState(this, "Checked", true);
 }
        public InsertGistControl()
        {
            ViewModel = new InsertGistViewModel();

            this.InitializeComponent();

            LayoutRoot.DataContext = ViewModel;

            var enter = Observable.FromEventPattern <MouseEventHandler, MouseEventArgs>(x => MouseEnter += x, x => MouseEnter -= x);
            var exit  = Observable.FromEventPattern <MouseEventHandler, MouseEventArgs>(x => MouseLeave += x, x => MouseLeave -= x);

            string currentOpenState = null;

            Observable.Merge(
                ViewModel.WhenAny(x => x.SelectionText, _ => "Base"),
                ViewModel.WhenAny(x => x.LastGistUrl, _ => "GistPosted").Where(x => x != null))
            .Subscribe(x => currentOpenState = x);

            var inRegionState = Observable.Merge(
                enter.Select(_ => currentOpenState),
                exit.Select(_ => "ButtonMode")).StartWith("ButtonMode")
                                .Throttle(TimeSpan.FromMilliseconds(800), RxApp.DeferredScheduler);

            var viewState = Observable.CombineLatest(
                ViewModel.WhenAny(x => x.SelectionText, x => !String.IsNullOrWhiteSpace(x.Value)),
                inRegionState,
                (hasSelection, selectionState) => hasSelection ? selectionState : "NoSelection");

            viewState.Subscribe(x => VisualStateManager.GoToElementState(LayoutRoot, x, true));

            ViewModel.WhenAny(x => x.LastGistUrl, x => x.Value)
            .Where(x => !String.IsNullOrWhiteSpace(x))
            .Subscribe(_ => VisualStateManager.GoToElementState(LayoutRoot, "GistPosted", true));
        }
Example #15
0
 private void capturaDatosDeProductoCargado(object sender, System.Windows.RoutedEventArgs e)
 {
     if (this.tabItemDatosDeProducto.IsSelected)
     {
         VisualStateManager.GoToElementState(this.LayoutRoot, "estadoDatosDeProductoCargado", true);
     }
 }
Example #16
0
 /// <summary>
 /// Updates the VSM state of the control
 /// </summary>
 private void UpdateState()
 {
     if (_gridButton != null)
     {
         VisualStateManager.GoToElementState(_gridButton, (IsSelected ? "SelectedNormal" : "Normal"), true);
     }
 }
Example #17
0
 private void datosDetallesCargado(object sender, System.Windows.RoutedEventArgs e)
 {
     if (this.tabItemDetalles.IsSelected)
     {
         VisualStateManager.GoToElementState(this.LayoutRoot, "estadoDetallesCargado", true);
     }
 }
Example #18
0
        void OnViewStateChanged(object sender, RoutedEventArgs e)
        {
            switch (_viewState)
            {
            case ViewState.New:
                VisualStateManager.GoToElementState(layoutRoot, "HidePostedGrid", false);
                VisualStateManager.GoToElementState(layoutRoot, "HideError", false);
                break;

            case ViewState.Saved:
                break;

            case ViewState.Edited:
                VisualStateManager.GoToElementState(layoutRoot, "HideError", false);
                VisualStateManager.GoToElementState(layoutRoot, "ShowPostedGrid", false);
                break;

            case ViewState.HasErrors:
                VisualStateManager.GoToElementState(layoutRoot, "ShowError", false);
                break;

            case ViewState.Deleted:
                break;

            default:
                break;
            }
        }
Example #19
0
 /// <summary>
 /// Overlay the full screen view of the image
 /// </summary>
 private void OnDisplayFullImage(object sender, RoutedEventArgs e)
 {
     // Always go to normal state before a transition
     this.SelectedImage = ((ContentControl)e.OriginalSource).Content as ImageSource;
     VisualStateManager.GoToElementState(OverlayGrid, NormalState, false);
     VisualStateManager.GoToElementState(OverlayGrid, FadeInTransitionState, false);
 }
Example #20
0
        private void GoToHidden(bool useTransition)
        {
            this.IsHitTestVisible = false;
            var appropriateHiddenState = this.GetHiddenState();

            VisualStateManager.GoToElementState(this.grid, appropriateHiddenState.Name, useTransition);
        }
Example #21
0
        private void OnHamburgerMenuClicked(object sender, RoutedPropertyChangedEventArgs <bool> e)
        {
            var shouldOpenMenuPanel = e.NewValue;

            VisualStateManager.GoToElementState(LayoutRoot, shouldOpenMenuPanel ? "OpenMenuPanel" : "CloseMenuPanel",
                                                true);
        }
Example #22
0
        private async void ConvertAndSaveGif()
        {
            SaveFileDialog dlg = new SaveFileDialog
            {
                FileName   = "asciiart",
                DefaultExt = ".gif",
                Filter     = "Image files (*.gif)|*.gif|All files (*.*)|*.*"
            };

            if (!(bool)dlg.ShowDialog())
            {
                return;
            }

            VisualStateManager.GoToElementState(GridMain, "GifShown", false);

            var options = CreateOptions();

            DrawingMode mode = GetDrawingMode();

            GifConverter converter = new GifConverter(options, mode);

            try
            {
                Progress <double> progress = new Progress <double>(UpdateProgress);
                await converter.ConvertAndSaveAsync(_source, new Uri(dlg.FileName), progress);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Operation failed!");
            }
        }
        /// <summary>
        /// Visuals the state changed.
        /// </summary>
        /// <param name="dependencyObject">The dependency object</param>
        /// <param name="eventArgs">The <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        public static void VisualStateChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs eventArgs)
        {
            //Control changeStateControl = d as Control;
            FrameworkElement changeStateControl = dependencyObject as FrameworkElement;

            if (changeStateControl == null)
            {
                throw (new ApplicationException("'VisualState' works only on Controls type"));
            }

            if (Application.Current.Dispatcher.CheckAccess() == false)
            {
                // Wrong thread
                System.Diagnostics.Debug.WriteLine("[VisualStateManagerEx] 'VisualStateChanged' event received on wrong thread -> re-route via Dispatcher");
                Application.Current.Dispatcher.BeginInvoke(
                    //() => { VisualStateChanged(d, e); }
                    VisualStateManagerEx.callback
                    , new object[] { dependencyObject, eventArgs });    //recursive
            }
            else
            {
                if (string.IsNullOrEmpty(eventArgs.NewValue.ToString()) == false)
                {
                    //VisualStateManager.GoToState(changeStateControl, e.NewValue.ToString(), true);
                    VisualStateManager.GoToElementState(changeStateControl, eventArgs.NewValue.ToString(), true);
                    System.Diagnostics.Debug.WriteLine("[VisualStateManagerEx] Visual state changed to " + eventArgs.NewValue.ToString());
                }
            }
        }
        private async void AskQuestion_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                VisualStateManager.GoToElementState(RootGrid, nameof(Asking), true);

                await GetOneAnswer();

                // await Get3Answers();
            }
            catch (Exception exception)
            {
                Response.Children.Insert(0,
                                         new TextBlock
                {
                    Text         = exception.Message,
                    TextWrapping = TextWrapping.Wrap,
                    Foreground   = new SolidColorBrush(Colors.Red),
                    Margin       = new Thickness(4)
                });
            }
            finally
            {
                VisualStateManager.GoToElementState(RootGrid, nameof(ReadyToAsk), true);
            }
        }
Example #25
0
        protected static void onStateObservableChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var This = (FollowObservableStateBehavior)sender;

            if (This.watcher != null)
            {
                This.watcher.Dispose();
                This.watcher = null;
            }

            This.watcher = ((IObservable <string>)e.NewValue).ObserveOn(RxApp.MainThreadScheduler).Subscribe(
                x => {
                var target = This.TargetObject ?? This.AssociatedObject;
#if SILVERLIGHT || NETFX_CORE
                VisualStateManager.GoToState(target, x, true);
#else
                if (target is Control)
                {
                    VisualStateManager.GoToState(target, x, true);
                }
                else
                {
                    VisualStateManager.GoToElementState(target, x, true);
                }
#endif
            },
                ex => {
                if (!This.AutoResubscribeOnError)
                {
                    return;
                }
                onStateObservableChanged(This, e);
            });
        }
Example #26
0
 internal static void StateChanged(DependencyObject target, DependencyPropertyChangedEventArgs args)
 {
     if (args.NewValue != null)
     {
         VisualStateManager.GoToElementState((FrameworkElement)target, args.NewValue.ToString(), true);
     }
 }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code
        /// or internal processes call System.Windows.FrameworkElement.ApplyTemplate().
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            PartBorder = (Border)GetTemplateChild("PART_Border");

            if (PartBorder == null)
            {
                return;
            }
            VisualStateManager.GoToElementState(PartBorder, (this.IsActive ? "Active" : "Inactive"), false);
            foreach (VisualStateGroup group in VisualStateManager.GetVisualStateGroups(PartBorder))
            {
                if (@group.Name != "ActiveStates")
                {
                    continue;
                }
                foreach (VisualState state in @group.States)
                {
                    if (state.Name == "Active")
                    {
                        state.Storyboard.SetSpeedRatio(PartBorder, this.SpeedRatio);
                    }
                }
            }

            PartBorder.Visibility = (this.IsActive ? Visibility.Visible : Visibility.Collapsed);
        }
Example #28
0
 private void capturaDeCantidadesCargado(object sender, System.Windows.RoutedEventArgs e)
 {
     if (this.tabItemCantidades.IsSelected)
     {
         VisualStateManager.GoToElementState(this.LayoutRoot, "estadoCapturaDeCantidadesCargado", true);
     }
 }
        public CheckForUpdatesView()
        {
            InitializeComponent();

            this.WhenAny(x => x.ViewModel.State, x => x.Value)
            .Where(x => x != null)
            .Subscribe(x => VisualStateManager.GoToElementState(Grid, x, true));

            this.BindCommand(ViewModel,
                             vm => vm.CheckCommand,
                             view => view.Next);

            this.BindCommand(ViewModel,
                             vm => vm.BackCommand,
                             view => view.Back);
            this.BindCommand(ViewModel,
                             vm => vm.BackCommand,
                             view => view.Back1);

            this.Bind(ViewModel,
                      vm => vm.Progress,
                      view => view.CheckingProgress.Value);

            this.Bind(ViewModel,
                      vm => vm.UseDeltaPackages,
                      view => view.UseDeltaPackages.IsChecked);
        }
Example #30
0
        /// <summary>
        /// Provides derived classes an opportunity to handle changes to the IsUploading property.
        /// </summary>
        protected virtual void OnIsUploadingChanged(DependencyPropertyChangedEventArgs e)
        {
            var val    = (bool)e.NewValue;
            var retval = VisualStateManager.GoToElementState(this, val ? "UploadingState" : "BaseState", true);

            Debug.WriteLine(retval);
        }