Esempio n. 1
0
        public async void AddToastWithTimeout(ToastViewModel toast, TimeSpan timeout)
        {
            AddToast(toast);
            await Task.Delay(timeout);

            RemoveToast(toast);
        }
Esempio n. 2
0
 public void UnholdToast(ToastViewModel toast)
 {
     toastsOnHold.Remove(toast);
     if (zombies.Remove(toast))
     {
         RemoveToastFromToasts(toast);
     }
 }
Esempio n. 3
0
        public Principal()
        {
            InitializeComponent();
            //Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = 5 });
            VIAJE_BUSQUEDA.IsTextSearchCaseSensitive = false;

            var instanceContext = new InstanceContext(this);

            _contenedorClient = new ContenedorClient(instanceContext);
            _contenedorClient.Subscribe();
            _contenedorSimpleClient = new ContenedorSimpleClient(instanceContext);
            _contenedorSimpleClient.Subscribe();

            Timer timer = new Timer();

            timer.Interval  = 180000;
            timer.Elapsed  += Timer_Elapsed;
            timer.AutoReset = true;
            timer.Start();

            _vm     = new ToastViewModel();
            options = new MessageOptions
            {
                FontSize                = 30,    // set notification font size
                ShowCloseButton         = true,  // set the option to show or hide notification close button
                FreezeOnMouseEnter      = false, // set the option to prevent notification dissapear automatically if user move cursor on it
                NotificationClickAction = n =>   // set the callback for notification click event
                {
                    n.Close();                   // call Close method to remove notification
                }
            };

            _Exportaciones = new ObservableCollection <Contenedor>(_contenedorClient.obtenerTodasExportaciones().AsEnumerable());
            _Importaciones = new ObservableCollection <Contenedor>(_contenedorClient.obtenerTodasImportaciones().AsEnumerable());

            //filtro = _Importaciones;
            //filtro2 = _Exportaciones;

            datosVisibles1      = new ObservableCollection <ContenedorSimple>(_contenedorSimpleClient.obtenerTodasImportaciones());
            datosVisibles1copia = new ObservableCollection <ContenedorSimple>(_contenedorSimpleClient.obtenerTodasImportaciones());

            datosVisibles2copia = new ObservableCollection <Contenedor>(_Exportaciones);
            autoCompletado      = new ActualizarAutoCompletado(); //buques en combobox

            construirFiltros();
            cargarFiltros();
            cargarFiltros2();
            colapsarColumnas();
            agrupacionDataGrid();
            paginacionImpo(num, 1);
            paginacionExpo(num, 1);

            //cambioRadioButton(checkViaje, null);
        }
Esempio n. 4
0
 public void RemoveToast(ToastViewModel toast)
 {
     if (toastsOnHold.Contains(toast))
     {
         zombies.Add(toast);
     }
     else
     {
         RemoveToastFromToasts(toast);
     }
 }
        public MainViewModel()
        {
            CommandInitialize();
            Notificate       = new ToastViewModel();
            ExchangerModel   = new Exchanger(this);
            Authorization    = new AuthorizationService();
            DisplayTextModel = new ScanCodeHandler();

            DecryptedSide = true;
            EncryptedSide = true;
        }
Esempio n. 6
0
 void RemoveToastFromToasts(ToastViewModel toast)
 {
     if (toasts.Count == 1)
     {
         CloseToastWindow();
         toasts = new ObservableCollection <ToastViewModel>();
     }
     else
     {
         toasts.Remove(toast);
     }
 }
Esempio n. 7
0
 public void AddToast(ToastViewModel toast)
 {
     zombies.Remove(toast);
     if (!toasts.Contains(toast))
     {
         toasts.Add(toast);
     }
     if (toasts.Count > 0)
     {
         OpenToastWindow();
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Position the notification in the bottom right of the screen and stack it on top of the other notifications if other exist.
        /// By getting how many other active notification windows there are, euther set the notification to the bottom right or set it so that it is above the last one.
        /// </summary>
        private void PositionTheNotification(ToastViewModel toast)
        {
            var width = SystemParameters.WorkArea.Width;
            var height = SystemParameters.WorkArea.Height;

            var i = GetActiveToastsCount();
            if (i > 0)
            {
                toast.Top = Notifications.Last(o => o.IsActive).Top - NotificationHeight;
            }
            else
            {
                toast.Top = height - NotificationHeight;
            }

            toast.Left = width - NotificationWidth;
            toast.Visible = Visibility.Visible;
            toast.IsActive = true;
        }
Esempio n. 9
0
        public async void Toast(ToastConfig config)
        {
            var vm = new ToastViewModel
            {
                Message          = config.Message,
                MessageTextColor = config.MessageTextColor,
                BackgroundColor  = config.BackgroundColor,
                PositionIn       = config.Position == ToastPosition.Top
                    ? MoveAnimationOptions.Top
                    : MoveAnimationOptions.Bottom,
                Tap = PopAction(() =>
                                config.OnTap?.Invoke()
                                )
            };
            var toast = new ToastPage
            {
                BindingContext = vm
            };
            await PopupNavigation.Instance.PushAsync(toast);

            Task.Delay(config.DisplayTime)
            .ContinueWith(_ => Pop());
        }
Esempio n. 10
0
        /// <summary>
        /// Creates the toast notification.
        /// </summary>
        /// <param name="result">The result.</param>
        /// <param name="isForTest">if set to <c>true</c> [is for test].</param>
        /// <param name="toastOnActivated">The toast on activated.</param>
        internal static void CreateToastNotification(BuildResult result, bool isForTest, EventHandler <EventArgs> toastOnActivated)
        {
            var toastView  = new ToastView();
            var toastModel = new ToastViewModel(toastView)
            {
                Title        = result.Name,
                MessageLine1 = isForTest ? "Running build will fail" : result.Status.ToString(),
                MessageLine2 = isForTest ? result.RunningBuildRequestedBy : result.RequestedBy,
            };

            toastView.DataContext = toastModel;

            toastView.Left = SystemParameters.FullPrimaryScreenWidth - toastView.Width - 10;
            var top = SystemParameters.FullPrimaryScreenHeight - toastView.Height;

            while (DisplayedToastViewHeights.Contains(top))
            {
                top -= toastView.Height + 10;
            }

            toastView.Top = top;
            DisplayedToastViewHeights.Add(top);

            string image = null;

            switch (result.Status)
            {
            case BuildStatus.InProgress:
                image = "inprogress_128";
                break;

            case BuildStatus.Stopped:
                image = "stop_128";
                break;

            case BuildStatus.PartiallySucceeded:
                image = "orange_128";
                break;

            case BuildStatus.Failed:
                image = "red_128";
                break;
            }

            if (isForTest)
            {
                image = "build_128";
            }

            if (image != null)
            {
                var uri = new Uri("pack://application:,,,/BuildMonitorWpf;component/Images/" + image + ".png");
                toastModel.Image = new BitmapImage(uri);
            }

            System.Media.SystemSounds.Hand.Play();
            toastView.Closing += ToastViewClosing;
            if (toastOnActivated != null)
            {
                toastView.MouseDown += (o, e) => toastOnActivated(o, e);
            }

            toastView.Show();
        }
Esempio n. 11
0
 public MainWindow()
 {
     InitializeComponent();
     _vm = new ToastViewModel();
 }
Esempio n. 12
0
        //Create Widget VM According to XML data
        public static WidgetViewModBase CreateWidget(IRegion obj)
        {
            //string timeStamp = "_" + DateTime.Now.ToString("MMddHHmmssfff");
            WidgetViewModBase vmItem;

            if (obj is IMaster)
            {
                IMaster master = obj as IMaster;
                AutoSetWdgName(obj, "Master ", WidgetType.None);
                vmItem = new MasterWidgetViewModel(master);
                return(vmItem);
            }

            IWidget it = obj as IWidget;

            switch (it.WidgetType)
            {
            case WidgetType.Button:
            {
                AutoSetWdgName(it, "Button ", WidgetType.Button);
                vmItem = new ButtonWidgetViewModel(it);
                break;
            }

            case WidgetType.Image:
            {
                AutoSetWdgName(it, "Image ", WidgetType.Image);
                vmItem = new ImageWidgetViewModel(it);
                break;
            }

            case WidgetType.SVG:
            {
                AutoSetWdgName(it, "Svg ", WidgetType.SVG);
                vmItem = new SVGWidgetViewModel(it);
                break;
            }

            case WidgetType.HotSpot:
            {
                AutoSetWdgName(it, "Link ", WidgetType.HotSpot);
                vmItem = new HotSpotWidgetViewModel(it);
                break;
            }

            case WidgetType.Line:
            {
                ILine line = it as ILine;
                if (line.Orientation == Orientation.Vertical)
                {
                    AutoSetWdgName(it, "VLine ", WidgetType.Line);
                    vmItem = new VLineWidgetViewModel(it);
                }
                else
                {
                    AutoSetWdgName(it, "HLine ", WidgetType.Line);
                    vmItem = new HLineWidgetViewModel(it);
                }
                break;
            }

            case WidgetType.Shape:
            {
                IShape shape = it as IShape;
                if (shape.ShapeType == ShapeType.Diamond)
                {
                    AutoSetWdgName(it, "Diamond ", WidgetType.Shape);
                    vmItem = new DiamondWidgetViewModel(it);
                }
                else if (shape.ShapeType == ShapeType.Ellipse)
                {
                    AutoSetWdgName(it, "Ellipse ", WidgetType.Shape);
                    vmItem = new CircleWidgetViewModel(it);
                }
                else if (shape.ShapeType == ShapeType.Rectangle)
                {
                    AutoSetWdgName(it, "Rectangle ", WidgetType.Shape);
                    vmItem = new RectangleWidgetViewModel(it);
                }
                else if (shape.ShapeType == ShapeType.RoundedRectangle)
                {
                    AutoSetWdgName(it, "Round ", WidgetType.Shape);
                    vmItem = new RoundedRecWidgetViewModel(it);
                }
                else if (shape.ShapeType == ShapeType.Paragraph)
                {
                    AutoSetWdgName(it, "Paragraph ", WidgetType.Shape);
                    vmItem = new LabelWidgetViewModel(it);
                }
                else if (shape.ShapeType == ShapeType.Triangle)
                {
                    AutoSetWdgName(it, "Triangle ", WidgetType.Shape);
                    vmItem = new TriangleWidgetViewModel(it);
                }
                else
                {
                    AutoSetWdgName(it, "Image ", WidgetType.Shape);
                    vmItem = new ImageWidgetViewModel(it);
                }

                break;
            }

            case WidgetType.ListBox:
            {
                AutoSetWdgName(it, "ListBox ", WidgetType.ListBox);
                vmItem = new ListboxWidgetViewModel(it);
                break;
            }

            case WidgetType.DropList:
            {
                AutoSetWdgName(it, "DropList ", WidgetType.DropList);
                vmItem = new DroplistWidgetViewModel(it);
                break;
            }

            case WidgetType.Checkbox:
            {
                AutoSetWdgName(it, "Checkbox ", WidgetType.Checkbox);
                vmItem = new CheckBoxWidgetViewModel(it);
                break;
            }

            case WidgetType.RadioButton:
            {
                AutoSetWdgName(it, "RadioButton ", WidgetType.RadioButton);
                vmItem = new RadioButtonWidgetViewModel(it);
                break;
            }

            case WidgetType.TextArea:
            {
                AutoSetWdgName(it, "TextArea ", WidgetType.TextArea);
                vmItem = new TextAreaWidgetViewModel(it);
                break;
            }

            case WidgetType.TextField:
            {
                AutoSetWdgName(it, "TextField ", WidgetType.TextField);
                vmItem = new TextFieldWidgetViewModel(it);
                break;
            }

            case WidgetType.HamburgerMenu:
            {
                AutoSetWdgName(it, "Drawer ", WidgetType.HamburgerMenu);
                vmItem = new HamburgerMenuViewModel(it);
                break;
            }

            case WidgetType.DynamicPanel:
            {
                AutoSetWdgName(it, "Flicking ", WidgetType.DynamicPanel);
                vmItem = new DynamicPanelViewModel(it);
                break;
            }

            case WidgetType.Toast:
            {
                AutoSetWdgName(it, "Toast ", WidgetType.Toast);
                vmItem = new ToastViewModel(it);
                break;
            }

            case WidgetType.FlowShape:
                // To avoid crash when load old file as we don't support flow shape right now.
                // This is temporary code and remove it once we support flow shape.
                return(null);

            case WidgetType.None:
                return(null);

            default:
            {
                vmItem = null;
                break;
            }
            }//switch
            return(vmItem);
        }
Esempio n. 13
0
 public void HoldToast(ToastViewModel toast)
 {
     toastsOnHold.Add(toast);
 }
        public ToastPage(string message)
        {
            InitializeComponent();

            BindingContext = new ToastViewModel(message);
        }
Esempio n. 15
0
 public static void SetToast(this ISession session, ToastViewModel toast) => session.SetObjectAsJson($"toast-{Guid.NewGuid()}", toast);
Esempio n. 16
0
 public ToastPage()
 {
     InitializeComponent();
     VM             = new ToastViewModel();
     BindingContext = VM;
 }