Example #1
0
        public void DisableControls(PopupView view)
        {
            Window parent = Window.GetWindow(this);

            EnableControls(parent);
            ScanAndDisableControls(parent, view);
        }
Example #2
0
        public void Show(PopupView popup)
        {
            // DebugUtils.Log("PopupManagerView.Show()");
            OnPreShow(popup);

            for (int i = 0; i < recentPopups.Length; ++i)
            {
                if (recentPopups[i] == popup)
                {
                    recentPopups[i] = null;
                    break;
                }
            }

            PopupView recentPopup = recentPopups[nextPopupIndex];

            if (recentPopup != null)
            {
                recentPopup.GetComponent <ShowableView>().Hide();
            }

            recentPopups[nextPopupIndex] = popup;
            ++nextPopupIndex;

            if (nextPopupIndex >= recentPopups.Length)
            {
                nextPopupIndex = 0;
            }

            var showable = popup.GetComponent <ShowableView>();

            DebugUtils.Assert(!showable.IsShown);
            showable.OnHide += OnPopupHide;
            showable.Show();
        }
Example #3
0
    //  TODO aherrera : second param: ePopupType?
    public void AddPopup(PopupModel.sPopupInfos popup_infos)
    {
        GameObject new_popup_go = Instantiate(PopupDefaultPrefab);
        PopupModel popup_model  = new_popup_go.GetComponent <PopupModel>();

        if (popup_model == null)
        {
            popup_model = new_popup_go.AddComponent <PopupModel>();
        }

        PopupView view = new_popup_go.GetComponent <PopupView>();

        if (view == null)
        {
            view = new_popup_go.gameObject.AddComponent <PopupView>();
        }

        //  TODO aherrera : IF you're gonna do enums and default popups, use popup_infos to setup the popup HERE
        //                      probably to the popup_model

        AddPopup(new_popup_go);

        popup_model.InitializePopup();
        //  view.Initialize?

        UpdatePopupInput();
    }
        //因为外部更改了category 这个也要通过show 更新
        //所以需要show 才能展示
        protected override void OnShow()
        {
            Clear();

            var data = ToDoDataManager.Data;

            if (data.categoryList.Count > 0)
            {
                popupView = new PopupView(0,
                                          data.categoryList.Select(x => x.name).ToArray())
                            .Width(100f).Height(20).AddTo(this);
            }


            var inputTextArea = new TextAreaView(todoName).Height(20).FontSize(15);

            inputTextArea.Content.Bind(x => todoName = x);
            Add(inputTextArea);

            var addBtn = new ImageButtonView(ImageButtonIcon.addIcon, () =>
            {
                if (!string.IsNullOrEmpty(todoName))
                {
                    onInputClick?.Invoke(ToDoDataManager.ToDoCategoryAt(PopupIndex), todoName);
                    inputTextArea.Content.Val = string.Empty;
                    GUI.FocusControl(null);
                }
            }).Width(30).Height(20).BackgroundColor(Color.yellow);

            Add(addBtn);
        }
Example #5
0
    public virtual void OnGUI(int column)
    {
        object v = this.GetValue(column);

        if (v is string[])
        {
            string[] path = v as string[];
            EditorGUILayout.Popup(0, path, GUILayout.Width(150));
        }
        else if (v is List <Material> )
        {
            if (GUILayout.Button("Materials " + (v as List <Material>).Count, GUILayout.Width(150)))
            {
                PopupView.Show((v as List <Material>).ToArray());
            }
        }
        else if (v is List <string> )
        {
            if (GUILayout.Button("String " + (v as List <string>).Count, GUILayout.Width(150)))
            {
                PopupView.Show((v as List <string>).ToArray());
            }
        }
        else if (v is List <Shader> )
        {
            if (GUILayout.Button("Shaders " + (v as List <Shader>).Count, GUILayout.Width(150)))
            {
                PopupView.Show((v as List <Shader>).ToArray());
            }
        }
        else if (v is List <Text> )
        {
            if (GUILayout.Button("Texts " + (v as List <Text>).Count, GUILayout.Width(150)))
            {
                PopupView.Show((v as List <Text>).ToArray());
            }
        }
        else if (v is Object)
        {
            EditorGUILayout.ObjectField(this.GetValue(column) as Object, typeof(Object), GUILayout.Width(150));
        }
        else
        {
            GUIStyle style = new GUIStyle(GUI.skin.label)
            {
                alignment = TextAnchor.MiddleCenter
            };
            style.normal.textColor = this.GetColor(column);
            object obj = this.GetValue(column);
            if (obj != null)
            {
                EditorGUILayout.LabelField(this.GetValue(column).ToString(), style, GUILayout.Width(150));
            }
            else
            {
                EditorGUILayout.LabelField("", style, GUILayout.Width(150));
            }
            GUI.skin.label.normal.textColor = Color.white;
        }
    }
Example #6
0
 /// <summary>
 /// Called on UI bus message.
 /// </summary>
 /// <param name="message">The message.</param>
 public void OnMessage(ApplicationMessage <UIBusMessageTypes> message)
 {
     try {
         switch (message.MessageType)
         {
         case UIBusMessageTypes.InformationRequest: {
             InformationRequest irqt = message.Payload as InformationRequest;
             if (irqt != null)
             {
                 WorkspaceViewModel vm = irqt.Tag as WorkspaceViewModel;
                 if (vm != null)
                 {
                     PopupView pw = new PopupView(vm);
                     pw.Owner = this.MainWindow;
                     pw.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                     if (pw.ShowDialog() == true)
                     {
                         irqt.CompleteMethod(irqt);
                     }
                 }
                 else if (irqt.ResultType == typeof(System.IO.File))
                 {
                     SelectFileName(irqt);
                 }
             }
         }
         break;
         }
     }
     catch (Exception x) {
         AppContext.Current.LogTechError(string.Format("Technical error {0}: {1}", x.GetType().Name, x.Message), x);
         System.Diagnostics.Debug.WriteLine(x.GetDetails());
     }
 }
Example #7
0
        private void OpenPopupExecute()
        {
            var    homeview = new HomeView();
            Window popup    = new PopupView(homeview, ResGeneral.Home);

            popup.ShowDialog();
        }
Example #8
0
        // PRAGMA MARK - Public Interface
        public void Init(Action battleHandler, Action levelEditorHandler, Action coopHandler)
        {
            battleHandler_      = battleHandler;
            levelEditorHandler_ = levelEditorHandler;
            coopHandler_        = coopHandler;

            levelEditorContainer_.SetActive(Application.isEditor);
                        #if UNITY_EDITOR || DEBUG
            coopContainer_.SetActive(true);
                        #else
            coopContainer_.SetActive(false);
                        #endif

            transition_.AnimateIn(() => {
                if (InGameConstants.IsAlphaBuild && !InGameConstants.ShowedAlphaDisclaimer)
                {
                    InGameConstants.ShowedAlphaDisclaimer = true;
                    popupView_ = PopupView.Create("<b>DISCLAIMER (please read):</b><size=25>\n\nThis is an PRE-ALPHA build of PHASERBEAK. It is not representive of how the final game and has undergone only basic testing and optimization. Please DO NOT distribute this build.\n\nIf you have any feedback or suggestions, join our Discord (through www.phaserbeak.com). Thanks for playing!\n\n-Darren", InputUtil.AllInputs, new PopupButtonConfig[] {
                        new PopupButtonConfig("ACCEPT", CreateSelectionView, defaultOption: true)
                    });
                }
                else
                {
                    CreateSelectionView();
                }
            });
        }
Example #9
0
        public bool TryAskText(string title, string label, string initVal, Action <string> newVal)
        {
            TextRqtVModel vm = new TextRqtVModel(title, label, initVal, newVal);
            PopupView     pw = new PopupView(vm);
            var           rz = pw.ShowDialog();

            return(rz == true);
        }
Example #10
0
        public PopupView Get(int popupType)
        {
            PopupView popupProto = popupProtos[popupType];
            int       poolId     = popupProto.GetComponent <PoolableView>().PoolId;

            return(poolStorage.Take(poolId)
                   .GetComponent <PopupView>());
        }
        protected override void OnPreShow(PopupView popup)
        {
            bool      isWorldPositionStays = false;
            Transform popupTransform       = popup.transform;

            popupTransform.SetParent(transform, isWorldPositionStays);
            popupTransform.SetAsLastSibling();
        }
Example #12
0
        /// <summary>
        /// Gets the opacity zero animation.
        /// </summary>
        /// <param name="popupView">The popup view.</param>
        /// <returns>Timeline.</returns>
        public static Timeline GetOpacityZeroAnimation(PopupView popupView)
        {
            //Defining Animation Attributes
            var animation = new DoubleAnimation { From = 1, To = 0, Duration = TimeSpan.FromSeconds(0.5) };
            Storyboard.SetTarget(animation, popupView);
            Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.Opacity)"));

            return animation;
        }
Example #13
0
    public static void Show(object[] content)
    {
        PopupView view = EditorWindow.GetWindow <PopupView>();

        view.Show();
        view.Objs.Clear();
        view.Objs.AddRange(content);
        view.Process();
    }
Example #14
0
        private void ShowPopupBtn_TouchUpInside(object sender, EventArgs e)
        {
            UIView alert = new UIView(new CGRect(0, 0, 100, 100));

            alert.BackgroundColor = UIColor.Red;

            PopupView view = PopupView.PopupViewWithContentView(alert);

            view.Show();
        }
Example #15
0
 public async static void CloseAll()
 {
     foreach (var child in PopupService._rootControl.Children)
     {
         if (child.GetType().Name == "PopupView")
         {
             PopupView pv = (PopupView)child;
             pv.Hide();
         }
     }
 }
Example #16
0
        public ItemsPage()
        {
            InitializeComponent();

            BindingContext = viewModel = new ItemsViewModel();

            CtrlPopup = new PopupView("Turnos", new Controls.TestCtrlView())
            {
                ShowPopup = false
            };
            var al = ((AbsoluteLayout)this.Content);

            al.Children.Add(CtrlPopup);
        }
Example #17
0
        private void popup_Opened(object sender, EventArgs e)
        {
            PopupView.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));

            if (SelectedForeignKey == 0)
            {
                SetSelectedForeignKey();
            }

            var iNotify = PopupView.DataContext as INotifyPropertyChanged;

            if (iNotify != null)
            {
                iNotify.PropertyChanged += INotify_PropertyChanged;
            }
        }
Example #18
0
 public async static void Close(UserControl viewToClose)
 {
     foreach (var child in PopupService._rootControl.Children)
     {
         if (child.GetType().Name == "PopupView")
         {
             PopupView pv = (PopupView)child;
             if (pv.MainContent.GetType().Name == viewToClose.GetType().Name)
             {
                 pv.Hide();
                 return;
             }
             ;
         }
     }
 }
Example #19
0
        /// <summary>Scan all the controls in the sub-VisualTree staring at node "depObj", and disable the appropriate ones
        /// A node should be disabled only if it does not satisfy neither of the following two criteria:
        /// (1) it is not configured to be enabled in popupView
        /// (2) none of its subnode is configured to be enabled in popupView
        /// </summary>
        /// <param name="depObj">A node in the visual tree</param>
        /// <param name="popupView">a PopupView</param>
        /// <returns>false if depObj is disabled, yes otherwise</returns>
        private bool ScanAndDisableControls(DependencyObject depObj, PopupView popupView)
        {
            if (depObj == PopupFrame)
            {
                return(true);
            }
            FrameworkElement control = depObj as FrameworkElement;

            if (control != null)
            {
                if (popupView != null)
                {
                    if (popupView.IsControlToAllowEnabled(control.Name))
                    {
                        return(true);
                    }
                }
            }
            bool hasChildrenToAllowEnabled = false;
            int  depObjCount = VisualTreeHelper.GetChildrenCount(depObj);

            for (int i = 0; i < depObjCount; i++)
            {
                if (ScanAndDisableControls(VisualTreeHelper.GetChild(depObj, i), popupView))
                {
                    hasChildrenToAllowEnabled = true;
                }
            }
            if (!hasChildrenToAllowEnabled)
            {
                if (control != null)
                {
                    if (control is ISupportUserInput)
                    {
                        (control as ISupportUserInput).AllowUserInput = false;
                    }
                    else if (control is Canvas)
                    {
                        control.IsEnabled = false;
                    }
                }
                return(false);
            }
            return(true);
        }
Example #20
0
 public void ShowPopup(bool isShowing, PopupView popupView, bool deferDisable)
 {
     this.deferDisable = deferDisable;
     if (isShowing)
     {
         if (0.0 == this.PopupFrame.Opacity)
         {
             this.currentPopupView = popupView;
             this.currentPopupView.ControlsToAllowEnableChanged += new EventHandler(CurrentPopupView_ControlsToAllowEnableChanged);
             if (this.popupRendering)
             {
                 this.PopupFrame.StopLoading();
             }
             this.popupRendering = true;
             if (null == this.PopupFrame.Content || !this.PopupFrame.Content.GetType().Equals(popupView.GetType()))
             {
                 this.PopupFrame.Navigate(popupView);
             }
             else
             {
                 PopupFrame_ContentRendered(this.PopupFrame, EventArgs.Empty);
             }
             ManageShroudEffect(deferDisable);
         }
         else
         {
             this.pendingPopup = popupView;
         }
     }
     else
     {
         if (this.currentPopupView != null)
         {
             this.currentPopupView.ControlsToAllowEnableChanged -= new EventHandler(CurrentPopupView_ControlsToAllowEnableChanged);
             this.popupToClose     = this.currentPopupView;
             this.currentPopupView = null;
         }
         if (popupView == null)
         {
             ManageShroudEffect(deferDisable);
         }
         Show(false);
         this.pendingPopup = null;
     }
 }
Example #21
0
        public static void PopupView(FormWindowState windowState = FormWindowState.Normal)
        {
            Cursor.Current = Cursors.WaitCursor;

            if (Application.OpenForms["PopupView"] == null)
            {
                PopupView action = new PopupView();
                action.Show();
            }
            else
            {
                {
                    Application.OpenForms["PopupView"].Activate();
                    Application.OpenForms["PopupView"].WindowState = windowState;
                    Application.OpenForms["PopupView"].Show();
                }
            }
        }
        public override void ViewDidLoad()
        {
            nfloat hPadding = 20;
            nfloat vPadding = View.Frame.Height / 6;

            nfloat x = hPadding;
            nfloat y = vPadding;
            nfloat w = View.Frame.Width - 2 * hPadding;
            nfloat h = View.Frame.Height - 2 * vPadding;

            Content = new PopupView(text);
            Content.ImageContainer.Items = images;
            Content.Frame      = new CGRect(x, y, w, h);
            Content.Label.Text = text;

            View.BackgroundColor = UIColor.FromRGBA(0, 0, 0, 0.5f);
            View.AddSubview(Content);
        }
Example #23
0
        public static bool IsToolbarVisible(UserControl viewToInterogate)
        {
            bool ret = false;

            foreach (var child in PopupService._rootControl.Children)
            {
                if (child.GetType().Name == "PopupView")
                {
                    PopupView pv = (PopupView)child;
                    if (pv.MainContent.GetType().Name == viewToInterogate.GetType().Name)
                    {
                        return(pv.ToolbarIsVisible);
                    }
                    ;
                }
            }

            return(ret);
        }
Example #24
0
        private void Awake()
        {
            var verticalLayout = new VerticalLayout("box").AddTo(this);


            new LabelView("描述").FontSize(15).AddTo(verticalLayout);

            contentTextArea = new TextAreaView("")
                              .Height(30).FontSize(20)
                              .ExpandHeight(true).AddTo(verticalLayout);

            enumPopupView = new PopupView(-1, null).AddTo(verticalLayout);

            showHideButton = new ButtonView("", _fullSize: true).AddTo(verticalLayout);

            saveButton = new ButtonView("保存", _fullSize: true).AddTo(verticalLayout);

            new ButtonView("取消", Close, _fullSize: true).AddTo(verticalLayout);
        }
Example #25
0
 private async static void Move(
     UserControl viewToMove,
     Thickness margin,
     SumoNinjaMonkey.Framework.Controls.PopupView.eCalloutAlign calloutAlign
     )
 {
     foreach (var child in PopupService._rootControl.Children)
     {
         if (child.GetType().Name == "PopupView")
         {
             PopupView pv = (PopupView)child;
             if (pv.MainContent.GetType().Name == viewToMove.GetType().Name)
             {
                 //pv.Margin = margin;
                 pv.Move(margin.Left, margin.Top);
                 pv.CalloutAlign = calloutAlign;
                 return;
             }
             ;
         }
     }
 }
        private void CrearNewChart_Clicked(object sender, EventArgs e)
        {
            StackLayout sl = new StackLayout();

            popup1            = new PopupView();
            popup1.PopupStyle = PopupViewStyle.Basic;
            ((PopupBasicStyle)popup1.Element[0]).Title = "My Popup";
            popup1.Show();

            /*
             * StackLayout basePopup = new StackLayout();
             * CustomCheckBox check1 = new CustomCheckBox();
             * CustomCheckBox check2 = new CustomCheckBox();
             * CustomCheckBox check3 = new CustomCheckBox();
             *
             * check1.Text = "Option 1";
             * check2.Text = "Option 2";
             * check3.Text = "Option 3";
             *
             * check1.Pressed += Check_Pressed;
             * check2.Pressed += Check_Pressed;
             * check3.Pressed += Check_Pressed;
             *
             * basePopup.BackgroundColor = Color.White;
             * basePopup.WidthRequest = 300;
             * basePopup.HeightRequest = 200;
             * basePopup.Children.Add(new Label() { Text = "Hola" });
             * basePopup.Children.Add(check1);
             * basePopup.Children.Add(check3);
             * basePopup.Children.Add(check2);
             * basePopup.HorizontalOptions = LayoutOptions.Center;
             * basePopup.VerticalOptions = LayoutOptions.Center;
             *
             * popup.Content = basePopup;
             *
             * ;
             */
        }
        private async void Map_Clicked(object sender, MapClickedEventArgs e)
        {
            Pin location = new Pin()
            {
                Type     = PinType.Place,
                Label    = "",
                Address  = "",
                Position = new Position(e.Position.Latitude, e.Position.Longitude),
            };

            Map.Pins.Add(location);

            PopupView      popupProperties = new PopupView(this, e.Position);
            ScaleAnimation scaleAnimation  = new ScaleAnimation
            {
                PositionIn  = MoveAnimationOptions.Right,
                PositionOut = MoveAnimationOptions.Left
            };

            popupProperties.Animation = scaleAnimation;

            await PopupNavigation.Instance.PushAsync(popupProperties, true);
        }
Example #28
0
        /// <summary>This is the main entrypoint of the application.</summary>
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            // Set the Current Culture.
            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            // Setup the Logger
            ILogger logger = LogManager.GetLogger();

            logger.Log(LogLevel.Info, "Loading the Application.");

            // Load up the Context & Engine
            Engine  engine  = null;
            Context context = null;

            {
                // Load the Accounts
                ObservableCollection <Account> accounts;
                try
                {
                    AccountsFactory accountFactory = new AccountsFactory();
                    accounts = accountFactory.Load();
                }
                catch (Exception ex)
                {
                    logger.Log(LogLevel.Error, "Failed to load the Accounts.", ex);
                    accounts = new ObservableCollection <Account>();
                }

                // Load the Sites
                ObservableCollection <Site> sites = null;
                try
                {
                    SitesFactory siteFactory = new SitesFactory();
                    sites = siteFactory.Load();
                }
                catch (Exception ex)
                {
                    logger.Log(LogLevel.Error, "Failed to load the Sites.", ex);
                    sites = new ObservableCollection <Site>();
                }

                // Load the AlertPreferences
                ObservableCollection <AlertPreference> alertPreferences = null;
                AlertPreferencesFactory alertPreferencesFactory         = new AlertPreferencesFactory();
                try
                {
                    alertPreferences = alertPreferencesFactory.Load();
                }
                catch (Exception ex)
                {
                    logger.Log(LogLevel.Error, "Failed to load the AlertPreferences.", ex);
                    alertPreferences = alertPreferencesFactory.CreateNew();
                }

                // Load the Scheduler
                Schedule scheduler = null;
                try
                {
                    ScheduleFactory schedulerFactory = new ScheduleFactory();
                    scheduler = schedulerFactory.Load();
                }
                catch (Exception ex)
                {
                    logger.Log(LogLevel.Error, "Failed to load the Scheduler.", ex);
                    scheduler = new Schedule();
                }

                // Check to see that we have a site for each account loaded
                foreach (Account account in accounts)
                {
                    Site site = sites.FirstOrDefault(s => s.SiteCode == account.SiteCode);
                    if (site == null)
                    {
                        PopulateSitesJob job = new PopulateSitesJob();
                        site = job.PopulateSite(sites, account);
                    }

                    account.Site = site;
                }

                // Load the Context
                context = new Context(accounts, sites, alertPreferences, scheduler);

                // Load the Engine
                engine = new Engine(context);

                DependencyFactory.RegisterInstance(context);
                DependencyFactory.RegisterInstance(engine);
            }

            // Create Initial Account (if no acount exists)
            if (context.Accounts.Count == 0)
            {
                logger.Log(LogLevel.Info, "No accounts exist. Creating initial account.");
                StartupWizardView      view      = new StartupWizardView();
                StartupWizardViewModel viewModel = (StartupWizardViewModel)view.DataContext;

                Application.Current.MainWindow = view;
                Application.Current.MainWindow.ShowDialog();
            }

            // If the user hit cancel and no accounts are saved, end the application
            if (context.Accounts.Count == 0)
            {
                Shutdown();
            }

            // Load up the Alert balloon
            try
            {
                logger.Log(LogLevel.Info, "Loading up the Alert balloons...");

                PopupView   view       = new PopupView();
                TaskbarIcon notifyIcon = (TaskbarIcon)FindResource("NotifyIcon");

                notifyIcon.ShowCustomBalloon(view, PopupAnimation.None, null);
            }
            catch (Exception ex)
            {
                logger.Log(LogLevel.Error, "Failed loading the alert balloons.", ex);
            }

            // Login.
            logger.Log(LogLevel.Info, "Performing Login...");
            engine.Login();
        }
Example #29
0
        /// <summary>
        /// Adds the slide from left animation.
        /// </summary>
        /// <param name="showStoryboard">The show storyboard.</param>
        /// <param name="popupView">The popup view.</param>
        public static void AddSlideFromLeftAnimation(Storyboard showStoryboard, PopupView popupView)
        {
            //Defining Animation Attributes
            var slideFromLeftAnimation = new DoubleAnimation
            {
                To = 0,
                BeginTime = TimeSpan.Zero,
                Duration = TimeSpan.Parse("00:00:01", CultureInfo.InvariantCulture),
                EasingFunction = new ElasticEase { Oscillations = 2, Springiness = 10 },
                AutoReverse = false
            };

            var adjustBackMarginAnimation = new ObjectAnimationUsingKeyFrames();
            var keyFrame = new DiscreteObjectKeyFrame { KeyTime = TimeSpan.Zero, Value = new Thickness(0, 0, 44, 0) };
            adjustBackMarginAnimation.KeyFrames.Add(keyFrame);
            Storyboard.SetTargetProperty(adjustBackMarginAnimation, new PropertyPath("(FrameworkElement.Margin)"));

            var backBody = popupView.GetChildrenByType<Control>(c => c.Name == "BackBody").FirstOrDefault();

            if (backBody != null)
                Storyboard.SetTarget(adjustBackMarginAnimation, backBody);

            var adjustMarginAnimation = new ObjectAnimationUsingKeyFrames();
            keyFrame = new DiscreteObjectKeyFrame { KeyTime = TimeSpan.Zero, Value = new Thickness(0, 0, 44, 0) };

            adjustMarginAnimation.KeyFrames.Add(keyFrame);
            Storyboard.SetTargetProperty(adjustMarginAnimation, new PropertyPath("(FrameworkElement.Margin)"));

            var borderBody = popupView.GetChildrenByType<Border>(c => c.Name == "BorderBody").FirstOrDefault();
            if (borderBody != null)
                Storyboard.SetTarget(adjustMarginAnimation, borderBody);

            var adjustDetailsButtonAnimation = new ObjectAnimationUsingKeyFrames();
            keyFrame = new DiscreteObjectKeyFrame { KeyTime = TimeSpan.Zero, Value = new Thickness(0, 0, 44, 0) };

            adjustDetailsButtonAnimation.KeyFrames.Add(keyFrame);
            Storyboard.SetTargetProperty(adjustDetailsButtonAnimation, new PropertyPath("(FrameworkElement.Margin)"));
            var detailsButton = popupView.GetChildrenByType<StackPanel>(c => c.Name == "DetailsButton").FirstOrDefault();
            if (detailsButton != null)
                Storyboard.SetTarget(adjustDetailsButtonAnimation, detailsButton);

            var adjustBackButtonAnimation = new ObjectAnimationUsingKeyFrames();
            keyFrame = new DiscreteObjectKeyFrame { KeyTime = TimeSpan.Zero, Value = new Thickness(0, 0, 44, 0) };

            adjustBackButtonAnimation.KeyFrames.Add(keyFrame);
            Storyboard.SetTargetProperty(adjustBackButtonAnimation, new PropertyPath("(FrameworkElement.Margin)"));
            var backButton = popupView.GetChildrenByType<HyperlinkButton>(c => c.Name == "BackButton").FirstOrDefault();
            if (backButton != null)
                Storyboard.SetTarget(adjustBackButtonAnimation, backButton);

            Storyboard.SetTarget(slideFromLeftAnimation, popupView);
            Storyboard.SetTargetProperty(slideFromLeftAnimation, new PropertyPath("(FrameworkElement.RenderTransform).(CompositeTransform.TranslateX)"));

            if (showStoryboard == null)
                return;

            showStoryboard.Children.Add(slideFromLeftAnimation);
            showStoryboard.Children.Add(adjustBackMarginAnimation);
            showStoryboard.Children.Add(adjustMarginAnimation);
            showStoryboard.Children.Add(adjustDetailsButtonAnimation);
            showStoryboard.Children.Add(adjustBackButtonAnimation);
        }
Example #30
0
        /// <summary>
        /// Adds the flip to top animation.
        /// </summary>
        /// <param name="hideStoryboard">The hide storyboard.</param>
        /// <param name="popupView">The popup view.</param>
        public static void AddFlipToTopAnimation(Storyboard hideStoryboard, PopupView popupView)
        {
            //Defining Animation Attributes
            var slideToTopAnimation = new DoubleAnimation { From = 0, To = 90, BeginTime = TimeSpan.Zero, Duration = TimeSpan.Parse("00:00:0.5", CultureInfo.InvariantCulture), AutoReverse = false };

            var centerOfRotationAnimationX = new DoubleAnimation { Duration = TimeSpan.Parse("0", CultureInfo.InvariantCulture), To = 0, };
            var centerOfRotationAnimationY = new DoubleAnimation { Duration = TimeSpan.Parse("0", CultureInfo.InvariantCulture), To = 0, };

            var layoutRoot = FindTopLevelPanel(popupView);
            Storyboard.SetTarget(slideToTopAnimation, layoutRoot);
            Storyboard.SetTargetProperty(slideToTopAnimation, new PropertyPath("(UIElement.Projection).(PlaneProjection.RotationX)"));

            Storyboard.SetTarget(centerOfRotationAnimationX, layoutRoot);
            Storyboard.SetTarget(centerOfRotationAnimationY, layoutRoot);
            Storyboard.SetTargetProperty(centerOfRotationAnimationX, new PropertyPath("(UIElement.Projection).(PlaneProjection.CenterOfRotationX)"));
            Storyboard.SetTargetProperty(centerOfRotationAnimationY, new PropertyPath("(UIElement.Projection).(PlaneProjection.CenterOfRotationY)"));

            if (hideStoryboard == null)
                return;

            hideStoryboard.Children.Add(centerOfRotationAnimationX);
            hideStoryboard.Children.Add(centerOfRotationAnimationY);
            hideStoryboard.Children.Add(slideToTopAnimation);
        }
Example #31
0
		public override void LoadView()
		{
			View = view = new PopupView();

		}
        protected override void Init(PopupView popupView)
        {
            base.Init(popupView);

            View.MessageText.text = Message;
        }
Example #33
0
        public async static void Show(
            UserControl viewToShow,
            UserControl toolbar,
            Brush accentPrimary,
            Brush accentSecondary,
            Brush foregroundTextBrush,
            Brush countdownBackgroundBrush,
            double timeToLive,
            Thickness margin,
            HorizontalAlignment horizontalAlignment = HorizontalAlignment.Center,
            VerticalAlignment verticalAlignment     = VerticalAlignment.Center,
            bool autoHide = false,
            double width  = 300,
            double height = 180,
            string button1ClickContent    = "",
            string button1ClickIdentifier = "",
            string button2ClickContent    = "",
            string button2ClickIdentifier = "",
            SumoNinjaMonkey.Framework.Controls.PopupView.eCalloutAlign calloutAlign = PopupView.eCalloutAlign.None,
            string button1MetroIcon   = "",
            double button1Rotation    = 0,
            string button2MetroIcon   = "",
            double button2Rotation    = 0,
            bool showPopupInnerBorder = true
            )
        {
            if (PopupService._rootControl != null)
            {
                DispatchedHandler invokedHandler = new DispatchedHandler(() =>
                {
                    if (PopupService._rootControl == null) //|| PopupService._rootControl.Visibility == Visibility.Visible)
                    {
                        //Move(viewToShow, margin, calloutAlign);

                        return;
                    }
                    PopupService._rootControl.Visibility = Visibility.Visible;
                    PopupView view = new PopupView(
                        viewToShow,
                        accentPrimary,
                        accentSecondary,
                        autoHide,
                        timeToLive,
                        button1ClickContent,
                        button1ClickIdentifier,
                        button2ClickContent,
                        button2ClickIdentifier,
                        width: width,
                        height: height,
                        button1MetroIcon: button1MetroIcon,
                        button1Rotation: button1Rotation,
                        button2MetroIcon: button2MetroIcon,
                        button2Rotation: button2Rotation,
                        toolbar: toolbar,
                        showInnerBorder: showPopupInnerBorder
                        );
                    view.ContentThickness    = new Thickness(0, 0, 0, 0);
                    view.HorizontalAlignment = horizontalAlignment;
                    view.VerticalAlignment   = verticalAlignment;
                    //view.Margin = margin;
                    view.BackgroundFill             = accentPrimary;
                    view.MessageTextForegroundColor = foregroundTextBrush;
                    view.CountdownBackgroundColor   = countdownBackgroundBrush;
                    view.Show(margin.Left, margin.Top);
                    view.CalloutAlign = calloutAlign;
                    view.OnClosing   += new EventHandler(PopupService.view_OnClosing);


                    PopupService._rootControl.Children.Add(view);
                });
                await PopupService._rootControl.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, invokedHandler);
            }
        }
Example #34
0
        /// <summary>
        /// Adds the flip from top animation.
        /// </summary>
        /// <param name="showStoryboard">The show storyboard.</param>
        /// <param name="popupView">The popup view.</param>
        public static void AddFlipFromTopAnimation(Storyboard showStoryboard, PopupView popupView)
        {
            var slideFromTopAnimation = new DoubleAnimation
            {
                From = -90,
                To = 0,
                BeginTime = TimeSpan.Zero,
                Duration = TimeSpan.Parse("00:00:0.75", CultureInfo.InvariantCulture),
                EasingFunction = new BounceEase() { EasingMode = EasingMode.EaseOut },
                AutoReverse = false
            };

            var adjustBackMarginAnimation = new ObjectAnimationUsingKeyFrames();
            var keyFrame = new DiscreteObjectKeyFrame { KeyTime = TimeSpan.Zero, Value = new Thickness(0, 44, 0, 0) };
            adjustBackMarginAnimation.KeyFrames.Add(keyFrame);
            Storyboard.SetTargetProperty(adjustBackMarginAnimation, new PropertyPath("(FrameworkElement.Margin)"));

            var backBody = popupView.GetChildrenByType<Control>(c => c.Name == "BackBody").FirstOrDefault();

            if (backBody != null)
                Storyboard.SetTarget(adjustBackMarginAnimation, backBody);

            var centerOfRotationAnimationX = new DoubleAnimation { Duration = TimeSpan.Parse("0", CultureInfo.InvariantCulture), To = 0, };
            var centerOfRotationAnimationY = new DoubleAnimation { Duration = TimeSpan.Parse("0", CultureInfo.InvariantCulture), To = 0, };

            var layoutRoot = FindTopLevelPanel(popupView);

            Storyboard.SetTarget(slideFromTopAnimation, layoutRoot);
            Storyboard.SetTarget(centerOfRotationAnimationX, layoutRoot);
            Storyboard.SetTarget(centerOfRotationAnimationY, layoutRoot);
            Storyboard.SetTargetProperty(centerOfRotationAnimationX, new PropertyPath("(UIElement.Projection).(PlaneProjection.CenterOfRotationX)"));
            Storyboard.SetTargetProperty(centerOfRotationAnimationY, new PropertyPath("(UIElement.Projection).(PlaneProjection.CenterOfRotationY)"));
            Storyboard.SetTargetProperty(slideFromTopAnimation, new PropertyPath("(UIElement.Projection).(PlaneProjection.RotationX)"));

            if (showStoryboard == null)
                return;

            showStoryboard.Children.Add(slideFromTopAnimation);
            showStoryboard.Children.Add(centerOfRotationAnimationX);
            showStoryboard.Children.Add(centerOfRotationAnimationY);
            showStoryboard.Children.Add(adjustBackMarginAnimation);
        }
Example #35
0
        /// <summary>
        /// Shows the specified on ok.
        /// </summary>
        /// <param name="onOk">The on ok.</param>
        /// <param name="onCancel">The on cancel.</param>
        /// <returns>PopupBuilder.</returns>
        public virtual PopupBuilder Show(Action onOk = null, Func<bool> onCancel = null)
        {
            OkCommand = null;
            _onCancel = onCancel;

            _customViewModelList = new ObservableCollection<INotificationViewModel>();

            if (_panel == null)
            {
                if (Application.Current.RootVisual == null) return this; //Runnig from Unit tests - no root visual
                _panel = PopupHelper.FindTopLevelPanel(Application.Current.RootVisual);
            }

            if (_position == PopupPosition.Right || _position == PopupPosition.Top)
                _parentPanel = GetStackPanel();
            else
                _parentPanel = GetGridPanel();

            if (_isModal)
            {
                _modalBorder = new Border
                                   {
                                       Opacity = 0.3,
                                       Background = new SolidColorBrush(Colors.LightGray),
                                       HorizontalAlignment = HorizontalAlignment.Stretch,
                                       VerticalAlignment = VerticalAlignment.Stretch,
                                   };
                _modalBorder.SetValue(Canvas.ZIndexProperty, ThePopupFactory.Value.NextZIndex());

                _parentPanel.Children.Add(_modalBorder);
            }

            if (_customViewModel != null)
            {
                _customViewModelList.Add(_customViewModel);
                if (_customViewModel is ISelectableList && onOk != null)
                {
                    (_customViewModel as ISelectableList).OnOK += PopupBuilderOnOK;
                    _popupBuilderOnOK = onOk;
                }
            }
            else
            {
                var commandList = CommandListFactory.CreateExport().Value;
                commandList.NotificationMessage = _message;

                _customViewModelList.Add(commandList);
            }

            _popupView = AddPopupControl(_parentPanel);

            if (CommandListVM != null) _customViewModelList.Add(CommandListVM);

            AddVisualStates(_popupView, _parentPanel);

            if (onOk != null)
            {
                CommandListVM = CommandListFactory.CreateExport().Value;
                if (_customViewModel != null)
                {
                    _customViewModel.InvokeOk = () => OkCommand.Execute(null);
                }

                OkCommand = new ActionCommand<object>(
                    o =>
                    {
                        if(ThePopupFactory.Value.Popups.Any(x=>x._isChild))
                            return;

                        HidePopup();
                        onOk();
                    },
                    o => !CommandListVM.HasErrors && (_customViewModel == null || !_customViewModel.HasErrors));

                var cancelCommand = onCancel == null ? new ActionCommand<object>(o => { }) : new ActionCommand<object>(o => CancelPopup(onCancel));

                AddCommandRange(
                    new List<ITitledCommand>
                        {
                            new TitledCommand(OkCommand, LanguageService.Translate("Label_OK"), string.Empty),
                            new TitledCommand(cancelCommand, LanguageService.Translate("Cmd_Cancel"), string.Empty)
                        });

                CommandListVM.Closed += CustomViewModelClosed;
            }

            if (CommandListVM != null)
            {
                CommandListVM.Orientation = _position == PopupPosition.Right ? Orientation.Vertical : Orientation.Horizontal;
            }

            ShowPopup();
            return this;
        }
Example #36
0
        /// <summary>
        /// Adds the notification states group.
        /// </summary>
        /// <param name="popupView">The popup view.</param>
        /// <param name="panel">The panel.</param>
        private void AddNotificationStatesGroup(PopupView popupView, Panel panel)
        {
            var uniqueId = Guid.NewGuid();
            var groups = (IList<VisualStateGroup>)VisualStateManager.GetVisualStateGroups(_panel);

            var vsGroup = new VisualStateGroup();
            groups.Add(vsGroup);
            vsGroup.SetValue(FrameworkElement.NameProperty, string.Format(CultureInfo.InvariantCulture, "NotificationState{0}", uniqueId));

            var hideState = new VisualState();
            var showState = new VisualState();
            var showCenterState = new VisualState();
            var showBusyState = new VisualState();

            var showStoryboard = new Storyboard();
            if (_position == PopupPosition.Top)
                PopupHelper.AddFlipFromTopAnimation(showStoryboard, popupView);
            else
                PopupHelper.AddSlideFromLeftAnimation(showStoryboard, popupView);

            showStoryboard.Completed += (o, args) =>
                {
                    if (_duration == 0)
                        return;
                    _timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(_duration) };
                    _timer.Start();
                    _timer.Tick += (sender, eventArgs) =>
                        {
                            if (!_isMouseOver)
                                HideNotificationPopup(_timer);
                            else
                                _timeToClose = true;
                        };
                };

            showState.Storyboard = showStoryboard;

            var hideStoryboard = new Storyboard();
            switch (_position)
            {
                case PopupPosition.Right:
                    hideStoryboard.Children.Add(PopupHelper.GetSlideToRightAnimation(popupView));
                    break;
                case PopupPosition.Top:
                    PopupHelper.AddFlipToTopAnimation(hideStoryboard, popupView);
                    break;
                default:
                    hideStoryboard.Children.Add(PopupHelper.GetOpacityZeroAnimation(popupView));
                    break;
            }

            _removeControlsAction = () =>
            {
                panel.Children.Remove(popupView);
                groups.Remove(vsGroup);
                if (_modalBorder != null)
                    _parentPanel.Children.Remove(_modalBorder);
            };

            hideStoryboard.Completed += (o, args) => RemoveControls();

            hideState.Storyboard = hideStoryboard;

            var showCenterStoryboard = new Storyboard();

            showCenterState.Storyboard = showCenterStoryboard;

            var showBusyStoryboard = new Storyboard();
            showBusyState.Storyboard = showBusyStoryboard;

            _showName = string.Format(CultureInfo.InvariantCulture, "Show{0}", uniqueId);
            _hideName = string.Format(CultureInfo.InvariantCulture, "Hide{0}", uniqueId);
            _showCenterName = string.Format(CultureInfo.InvariantCulture, "ShowCenter{0}", uniqueId);
            _showBusyName = string.Format(CultureInfo.InvariantCulture, "ShowBusy{0}", uniqueId);

            showState.SetValue(FrameworkElement.NameProperty, _showName);
            hideState.SetValue(FrameworkElement.NameProperty, _hideName);
            showCenterState.SetValue(FrameworkElement.NameProperty, _showCenterName);
            showBusyState.SetValue(FrameworkElement.NameProperty, _showBusyName);

            vsGroup.States.Add(showState);
            vsGroup.States.Add(showCenterState);
            vsGroup.States.Add(hideState);
            vsGroup.States.Add(showBusyState);
        }
Example #37
0
 /// <summary>
 /// Adds the visual states.
 /// </summary>
 /// <param name="popupView">The popup view.</param>
 /// <param name="stackPanel">The stack panel.</param>
 private void AddVisualStates(PopupView popupView, Panel stackPanel)
 {
     AddNotificationStatesGroup(popupView, stackPanel);
 }
Example #38
0
        /// <summary>
        /// Adds the popup control.
        /// </summary>
        /// <param name="parentPanel">The parent panel.</param>
        /// <returns>PopupView.</returns>
        private PopupView AddPopupControl(Panel parentPanel)
        {
            var popupView = new PopupView
                                {
                                    Name = string.Format(CultureInfo.InvariantCulture, "popupDialog{0}", parentPanel.Children.Count),
                                    DataContext = this,
                                    IsHitTestVisible = true,
                                    Visibility = Visibility.Visible,
                                };

            switch (_position)
            {
                case PopupPosition.Top:
                case PopupPosition.Right:
                    {
                        popupView.HorizontalAlignment = HorizontalAlignment.Right;
                        popupView.VerticalAlignment = VerticalAlignment.Bottom;
                        popupView.Margin = new Thickness(0, 0, -50, 5);
                        popupView.RenderTransformOrigin = new Point(0.5, 0.5);

                        var transform = new CompositeTransform { Rotation = 0, ScaleX = 1, ScaleY = 1, SkewX = 0, SkewY = 0 };
                        switch (_position)
                        {
                            case PopupPosition.Right:
                                transform.TranslateX = 280;
                                transform.TranslateY = 0;
                                break;
                            case PopupPosition.Top:
                                transform.TranslateX = 0;
                                transform.TranslateY = 0;
                                break;
                        }

                        popupView.RenderTransform = transform;
                    }

                    break;
                case PopupPosition.Center:
                    popupView.HorizontalAlignment = HorizontalAlignment.Center;
                    popupView.VerticalAlignment = VerticalAlignment.Center;
                    popupView.IsCentered = true;
                    popupView.SizeChanged += PopupView_SizeChanged;
                    break;
                default:
                    popupView.HorizontalAlignment = HorizontalAlignment.Left;
                    popupView.VerticalAlignment = VerticalAlignment.Top;
                    popupView.Margin = new Thickness(_location.X, _location.Y - 10, 0, 0);
                    popupView.IsCentered = true;
                    popupView.SizeChanged += PopupView_SizeChanged;
                    break;
            }

            ZIndex = ThePopupFactory.Value.NextZIndex();
            if (_modalBorder != null)
                ZIndex = Canvas.GetZIndex(_modalBorder) + 1;
            popupView.SetValue(Canvas.ZIndexProperty, ZIndex);
            popupView.Name = Guid.NewGuid().ToString();
            parentPanel.Children.Insert(0, popupView);
            ThePopupFactory.Value.Popups.Add(this);
            popupView.MouseEnter += _popupView_MouseEnter;
            popupView.MouseLeave += _popupView_MouseLeave;

            Application.Current.RootVisual.AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(RootVisual_KeyDown), true);

            return popupView;
        }
Example #39
0
 protected virtual void OnPreShow(PopupView popup)
 {
 }