Beispiel #1
0
        public static async Task MakeLikeAsync(ICanChangeLikModel model, Windows.UI.Core.CoreDispatcher dispatcher, SymbolIcon like, SymbolIcon coloredLike)
        {
            if (model == null)
            {
                return;
            }

            bool isReply = model is FeedReplyModel;
            var  u       = UriProvider.GetUri(
                model.Liked ? UriType.OperateUnlike : UriType.OperateLike,
                isReply ? "Reply" : string.Empty, model.Id);
            var o = (JObject) await GetDataAsync(u, true);

            await dispatcher?.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                model.Liked = !model.Liked;
                if (isReply)
                {
                    model.Likenum = o.ToString().Replace("\"", string.Empty);
                }
                else if (o != null)
                {
                    model.Likenum = $"{o.Value<int>("count")}";
                }

                if (like != null)
                {
                    like.Visibility = model.Liked ? Visibility.Visible : Visibility.Collapsed;
                }
                if (coloredLike != null)
                {
                    coloredLike.Visibility = model.Liked ? Visibility.Collapsed : Visibility.Visible;
                }
            });
        }
 public MockLightingServiceHandler(string name, string id, bool isDimmable, bool supportsColor, bool supportsTemperature, Windows.UI.Core.CoreDispatcher dispatcher)
 {
     this.dispatcher = dispatcher;
     Name            = name;
     Id = id;
     LampDetails_Color = supportsColor;
     LampDetails_ColorRenderingIndex    = 80;
     LampDetails_Dimmable               = isDimmable;
     LampDetails_HasEffects             = true;
     LampDetails_IncandescentEquivalent = 60;
     LampDetails_LampBaseType           = (uint)1;
     LampDetails_LampBeamAngle          = 130;
     LampDetails_LampID         = id;
     LampDetails_LampType       = (uint)1;
     LampDetails_Make           = (uint)AdapterLib.LsfEnums.LampMake.MAKE_OEM1;
     LampDetails_MaxLumens      = 1000;
     LampDetails_MaxTemperature = (uint)(supportsTemperature ? 9000 : 2800);
     LampDetails_MaxVoltage     = 120;
     LampDetails_MinTemperature = 2800;
     colorTemp = kelvinToUInt(LampDetails_MinTemperature);
     LampDetails_MinVoltage        = 100;
     LampDetails_Model             = 1;
     LampDetails_Type              = (uint)AdapterLib.LsfEnums.DeviceType.TYPE_LAMP;
     LampDetails_VariableColorTemp = supportsTemperature;
     LampDetails_Version           = 1;
     LampDetails_Wattage           = 7;
     if (!supportsColor)
     {
         saturation = 0;
     }
 }
Beispiel #3
0
        //public ObservableCollection<clsDevType> DevTypes = new ObservableCollection<clsDevType>();

        async void WatchDevices_Click(object sender, RoutedEventArgs eventArgs)
        {
            if (watcher != null)
            {
                watcher = null;
            }
            count = 0;
            isEnumerationComplete = false;
            StopStatus            = null;
            //DeviceInterfacesOutputList.Items.Clear();

            try
            {
                dispatcher = Window.Current.CoreWindow.Dispatcher;
                watcher    = DeviceInformation.CreateWatcher();
                // Add event handlers
                watcher.Added   += watcher_Added;
                watcher.Removed += watcher_Removed;
                watcher.Updated += watcher_Updated;
                watcher.EnumerationCompleted += watcher_EnumerationCompleted;
                watcher.Stopped += watcher_Stopped;
                watcher.Start();
                OutputText.Text = "Enumeration started.";

                this.btnWatchDevices.IsEnabled = false;
                this.btnStop.IsEnabled         = !(this.btnWatchDevices.IsEnabled);
            }
            catch (ArgumentException)
            {
                //The ArgumentException gets thrown by FindAllAsync when the GUID isn't formatted properly
                //The only reason we're catching it here is because the user is allowed to enter GUIDs without validation
                //In normal usage of the API, this exception handling probably wouldn't be necessary when using known-good GUIDs
                OutputText.Text = "Caught ArgumentException. Failed to create watcher.";
            }
        }
        public FlickrViewModel(Windows.UI.Core.CoreDispatcher dispatcher)
        {
            

            _dispatcher = dispatcher;

        }
Beispiel #5
0
        private async Task Init()
        {
            // Get dispatcher:
            Dispatcher_UWP = Dispatcher;

            // Get INTEGRA7Random.MainPage:
            MainPage_Portable = Integra7Random.MainPage.GetMainPage();
            UIHandler.appType = UIHandler._appType.UWP;

            // Get the generic handler (same way as done in Integra7Random.UIHandler):
            genericHandlerInterface = (Integra7Random.UWP.GenericHandlerInterface)DependencyService.Get <IGenericHandler>();

            // Let genericHandlerInterface know this MainPage:
            genericHandlerInterface.mainPage = this;

            // Let portable know this MainPage:
            MainPage_Portable.MainPage_Device = this;

            // Draw UI (function is in mainPage.uIHandler):
            //await Task.Run(() => MainPage_Portable.uIHandler.ShowLibrarianPage());
            MainPage_Portable.uIHandler.ShowLibrarianPage();

            // We need invisible ComboBoxes to hold settings from the
            // corresponding Pickers in the Xamarin code.
            OutputSelector = MainPage_Portable.uIHandler.Librarian_midiOutputDevice;
            InputSelector  = MainPage_Portable.uIHandler.Librarian_midiInputDevice;

            MainPage_Portable.SetDeviceSpecificMainPage(this);

            MainPage_Portable.uIHandler.commonState.midi.Init(MainPage_Portable, "INTEGRA-7", OutputSelector, InputSelector, (object)Dispatcher_UWP, 0, 0);

            // Always start by showing librarian:
            MainPage_Portable.uIHandler.ShowLibrarianPage();
        }
Beispiel #6
0
        public MainPage()
        {
            this.InitializeComponent();

            UIDispatcher = Windows.UI.Xaml.Window.Current.CoreWindow.Dispatcher;

            XboxLiveUser.SignOutCompleted += XboxLiveUser_SignOutCompleted;
            Windows.Networking.Connectivity.NetworkInformation.NetworkStatusChanged += new Windows.Networking.Connectivity.NetworkStatusChangedEventHandler(
                (object sender) =>
            {
                UpdateInternetAccessUI();
            });

            bool APIExist = Windows.Foundation.Metadata.ApiInformation.IsMethodPresent("Windows.System.UserPicker", "IsSupported");

            m_isMultiUserApplication = APIExist && Windows.System.UserPicker.IsSupported();

            // Only show the file picker for PC
            var deviceFamily = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily;

            if (deviceFamily != "Windows.Desktop")
            {
                SocialGroup_CustomList.Visibility = Visibility.Collapsed;
                ImportSocialGroup_List.Visibility = Visibility.Collapsed;
            }

            m_socialManagerUI.Init(this);
            CompositionTarget.Rendering += CompositionTarget_Rendering;

            UpdateInternetAccessUI();
            SignInSilently();

            ReadLastCsv();
        }
 public MockLightingServiceHandler(string name, string id, bool isDimmable, bool supportsColor, bool supportsTemperature, Windows.UI.Core.CoreDispatcher dispatcher)
 {
     this.dispatcher = dispatcher;
     Name = name;
     Id = id;
     LampDetails_Color = supportsColor;
     LampDetails_ColorRenderingIndex = 80;
     LampDetails_Dimmable = isDimmable;
     LampDetails_HasEffects = true;
     LampDetails_IncandescentEquivalent = 60;
     LampDetails_LampBaseType = (uint)1;
     LampDetails_LampBeamAngle = 130;
     LampDetails_LampID = id;
     LampDetails_LampType = (uint) 1;
     LampDetails_Make = (uint)AdapterLib.LsfEnums.LampMake.MAKE_OEM1;
     LampDetails_MaxLumens = 1000;
     LampDetails_MaxTemperature = (uint)(supportsTemperature ? 9000 : 2800);
     LampDetails_MaxVoltage = 120;
     LampDetails_MinTemperature = 2800;
     colorTemp = kelvinToUInt(LampDetails_MinTemperature);
     LampDetails_MinVoltage = 100;
     LampDetails_Model = 1;
     LampDetails_Type = (uint)AdapterLib.LsfEnums.DeviceType.TYPE_LAMP;
     LampDetails_VariableColorTemp = supportsTemperature;
     LampDetails_Version = 1;
     LampDetails_Wattage = 7;
     if (!supportsColor) saturation = 0;
 }
 public UwpMidiAccess(Windows.UI.Core.CoreDispatcher dispatcher)
 {
     _midiInDeviceWatcher  = new MidiDeviceWatcher(MidiInPort.GetDeviceSelector(), dispatcher);
     _midiOutDeviceWatcher = new MidiDeviceWatcher(MidiOutPort.GetDeviceSelector(), dispatcher);
     _midiInDeviceWatcher.Start();
     _midiOutDeviceWatcher.Start();
 }
Beispiel #9
0
        public MainPage()
        {
            //Initialising stuff
            teaTimer   = new Timer();
            alarmSound = new MediaElement();
            activeTea  = new Tea("", "", 0, 0, 0, 0, 0);
            highlight  = (SolidColorBrush)Application.Current.Resources["Highlight"];
            lowlight   = (SolidColorBrush)Application.Current.Resources["Lowlight"];
            teaInfo    = "";
            presetRows = new List <DataGridRow>();
            //BgBrush
            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.XamlCompositionBrushBase"))
            {
                bgBrush.BackgroundSource = Windows.UI.Xaml.Media.AcrylicBackgroundSource.HostBackdrop;
                bgBrush.TintColor        = Windows.UI.Color.FromArgb(255, 35, 35, 35);
                bgBrush.FallbackColor    = Windows.UI.Color.FromArgb(255, 31, 31, 31);
                bgBrush.TintOpacity      = 0.8;

                this.Background = bgBrush;
            }
            else
            {
                SolidColorBrush myBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 202, 24, 37));

                this.Background = bgBrush;
            }

            //Init timer so it displays at 0 seconds at the start
            teaTimer.Clear();

            //Load stuff from files
            LoadAlarmFile();
            LoadPresetsFromFile();
            settings = new AppSettings(this);
            //ApplySettings(settings);


            //Get dispatcher for main loop
            Windows.UI.Core.CoreWindow appWindow = Windows.UI.Core.CoreWindow.GetForCurrentThread();
            appDispatcher = appWindow.Dispatcher;

            //Minimum size
            var  view     = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
            Size viewSize = new Size {
                Width = 500, Height = 356
            };

            view.SetPreferredMinSize(viewSize);
            view.TryResizeView(viewSize);

            //event handlers for window activated / mainpage loadeds
            appWindow.Activated += AppWindow_Activated;
            this.Loaded         += MainPage_Loaded;

            this.InitializeComponent();

            //------------------------------- Main Loop -------------------------------
            MainLoop();
        }
        public MainPage()
        {
			dispatcher = Window.Current.CoreWindow.Dispatcher;
			InitializeToaster();
            this.InitializeComponent();			
			ToastingIndicator.IsEnabled = false;
			SetVersionText();
        }
 public BoardGamePageViewModel()
 {
     if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled)
     {
         dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;
         Messenger.Default.Register <RefreshDataMessage>(this, RefreshData);
     }
 }
Beispiel #12
0
 public HotItemsViewModel()
 {
     if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled)
     {
         dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;
         LoadHotItemsList();
     }
 }
 public MainPage()
 {
     dispatcher = Window.Current.CoreWindow.Dispatcher;
     InitializeToaster();
     this.InitializeComponent();
     ToastingIndicator.IsEnabled = false;
     SetVersionText();
 }
Beispiel #14
0
        public VisualGameManager(Windows.UI.Core.CoreDispatcher uiDispatcher)
        {
            this.uiDispatcher = uiDispatcher;
            State             = "Ok";
            IsError           = false;

            chessBoard = new ObservableChessBoard(Logic.Board, uiDispatcher);
        }
Beispiel #15
0
        private async void StartReceiverButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                dispatcher = Window.Current.CoreWindow.Dispatcher;

                if (receiver == null)
                {
                    receiver = new Windows.Media.PlayTo.PlayToReceiver();
                }

                // Add Play To Receiver events and properties
                receiver.CurrentTimeChangeRequested  += receiver_CurrentTimeChangeRequested;
                receiver.MuteChangeRequested         += receiver_MuteChangeRequested;
                receiver.PauseRequested              += receiver_PauseRequested;
                receiver.PlaybackRateChangeRequested += receiver_PlaybackRateChangeRequested;
                receiver.PlayRequested         += receiver_PlayRequested;
                receiver.SourceChangeRequested += receiver_SourceChangeRequested;
                receiver.StopRequested         += receiver_StopRequested;
                receiver.TimeUpdateRequested   += receiver_TimeUpdateRequested;
                receiver.VolumeChangeRequested += receiver_VolumeChangeRequested;

                // <SnippetProperties>
                receiver.FriendlyName  = "Sample Play To Receiver";
                receiver.SupportsAudio = false;
                receiver.SupportsVideo = true;
                receiver.SupportsImage = false;
                // </SnippetProperties>

                // Add MediaElement events
                VideoPlayer.CurrentStateChanged += VideoPlayer_CurrentStateChanged;
                VideoPlayer.MediaEnded          += VideoPlayer_MediaEnded;
                VideoPlayer.MediaFailed         += VideoPlayer_MediaFailed;
                VideoPlayer.MediaOpened         += VideoPlayer_MediaOpened;
                VideoPlayer.RateChanged         += VideoPlayer_RateChanged;
                VideoPlayer.SeekCompleted       += VideoPlayer_SeekCompleted;
                VideoPlayer.VolumeChanged       += VideoPlayer_VolumeChanged;

                // <SnippetStartAsync>
                // Advertise the receiver on the local network and start receiving commands
                await receiver.StartAsync();

                // Prevent the screen from locking
                if (display == null)
                {
                    display = new Windows.System.Display.DisplayRequest();
                }
                display.RequestActive();

                StatusTextBlock.Text = "'" + receiver.FriendlyName + "' started.";
                // </SnippetStartAsync>
            }
            catch
            {
                receiver             = null;
                StatusTextBlock.Text = "Failed to start receiver.";
            }
        }
Beispiel #16
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Default constructor.
        /// </summary>
        ///-------------------------------------------------------------------------------------------------
        public UIDispatcher()
        {
            var t = Windows.UI.Core.CoreWindow.GetForCurrentThread();

            if (t != null)
            {
                _dispatcher = t.Dispatcher;
            }
        }
        public SharingDialogViewModel(Windows.UI.Core.CoreDispatcher Dispatcher)
        {
            this.Dispatcher = Dispatcher;
            this.manager = new ShareTargetsManager();
            this.manager.ShareComplete += manager_ShareComplete;

            this.CancelCommand = new DelegateCommand(CancelCommandExecute);
            this.ShareCommand = new DelegateCommand(ShareCommandExecute, CanShareCommandExecute);
        }
        internal void OnNavigateToBase(Windows.UI.Core.CoreDispatcher dispatcher)
        {
            _vm = new HomeViewModel();
            _vm.Load();

            _fvm = new FlickrViewModel(Dispatcher);

            Messenger.Default.Register <GeneralSystemWideMessage>(this, DoGeneralSystemWideMessageCallback);
        }
Beispiel #19
0
        public ClockData()
        {
            var cwnd = Windows.UI.Core.CoreWindow.GetForCurrentThread();

            if (cwnd != null)
            {
                Dispatcher = cwnd.Dispatcher;
            }
        }
        public ViewModelBase()
        {
            var window = Windows.UI.Core.CoreWindow.GetForCurrentThread();

            if (window != null)
            {
                _dispatcher = window.Dispatcher;
            }
        }
        private void Initialize()
        {
            xboxLiveUser = new XboxLiveUser();
            Windows.ApplicationModel.Core.CoreApplicationView mainView = Windows.ApplicationModel.Core.CoreApplication.MainView;
            Windows.UI.Core.CoreWindow cw = mainView.CoreWindow;

            UIDispatcher = cw.Dispatcher;

            Refresh();
        }
Beispiel #22
0
 private async void Dispatcher_AcceleratorKeyActivated(Windows.UI.Core.CoreDispatcher sender,Windows.UI.Core.AcceleratorKeyEventArgs args)
 {
     if (args.EventType.ToString().Equals("KeyDown"))
     {
         Page_KeyDown(sender,args.VirtualKey);
     }
     if (args.EventType.ToString().Equals("KeyUp"))
     {
         Page_KeyUp(sender,args.VirtualKey);
     }
 }
Beispiel #23
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {
            Frame rootFrame = Window.Current.Content as Frame;
            dispatcher = Windows.UI.Xaml.Window.Current.Dispatcher;
            SettingsPane.GetForCurrentView().CommandsRequested += App_CommandsRequested;
            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active

            if (rootFrame == null)
            {


                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                //Associate the frame with a SuspensionManager key                                
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        //Something went wrong restoring state.
                        //Assume there is no state and continue
                    }
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }
            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(Views.Home)))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();

            //if (System.Diagnostics.Debugger.IsAttached)
            //{
            //    //Display the metro grid helper
            //    MC.MetroGridHelper.MetroGridHelper.CreateGrid();
            //}
        }
 public ShareTargetsViewModel(Windows.UI.Core.CoreDispatcher dispatcher)
 {
     this.Dispatcher = dispatcher;
     Targets = new ObservableCollection<ShareTarget>();
     Share = new DelegateCommand(TargetSelected, ShareEnabled);
     manager = new ShareTargetsManager();
     manager.ShareStarted += manager_ShareStarted;
     manager.ShareComplete += manager_ShareComplete;
     manager.ShareFailed += manager_ShareFailed;
     manager.PeerDiscoveryComplete += model_PeerDiscoveryComplete;
     manager.PeerDiscovered += model_PeerDiscovered;
 }
Beispiel #25
0
        public MainPage()
        {
            this.InitializeComponent();
            m_dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;

            Chilkat.Global glob = new Chilkat.Global();
            m_unlocked = glob.UnlockBundle("Anything for 30-day trial");
            if (!m_unlocked)
            {
                m_unlockError = glob.LastErrorText;
            }
        }
Beispiel #26
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            dispatcher = Windows.UI.Xaml.Window.Current.Dispatcher;
            SettingsPane.GetForCurrentView().CommandsRequested += App_CommandsRequested;
            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active

            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                //Associate the frame with a SuspensionManager key
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        //Something went wrong restoring state.
                        //Assume there is no state and continue
                    }
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }
            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(Views.Home)))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();

            //if (System.Diagnostics.Debugger.IsAttached)
            //{
            //    //Display the metro grid helper
            //    MC.MetroGridHelper.MetroGridHelper.CreateGrid();
            //}
        }
Beispiel #27
0
        public MainPageViewModel()
        {
            this.StartScaningCommand = new DelegateCommand(StartScaning);
            this.StopScaningCommand  = new DelegateCommand(StopScaning);

            this.watcher = new BluetoothLEAdvertisementWatcher();
            this.watcher.SignalStrengthFilter.InRangeThresholdInDBm    = -80;
            this.watcher.SignalStrengthFilter.OutOfRangeThresholdInDBm = -85;
            this.watcher.SignalStrengthFilter.OutOfRangeTimeout        = TimeSpan.FromMilliseconds(2000);
            this.watcher.Received += this.Watcher_Received;

            this.dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;
        }
Beispiel #28
0
        public MainPage()
        {
            UIDispater = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;
            this.InitializeComponent();
            InitBackground();
            InitStatusGridViewHeight();
            InitPicGridViewMaxRow();

            NavigationCacheMode = NavigationCacheMode.Enabled;
            PictureGridView.AddHandler(UIElement.PointerWheelChangedEvent, new Windows.UI.Xaml.Input.PointerEventHandler(OnPointerWheelChanged), true);
            StatusGridView.AddHandler(UIElement.PointerWheelChangedEvent, new Windows.UI.Xaml.Input.PointerEventHandler(OnPointerWheelChanged), true);
            this.DataContext = App.MainViewModel;
            InitSettingPane();
        }
Beispiel #29
0
        protected override void OnSearchActivated(SearchActivatedEventArgs args)
        {
            base.OnSearchActivated(args);
            var previousContent = Window.Current.Content;
            var frame           = previousContent as Frame ?? new Frame();

            Dispatcher = Window.Current.Dispatcher;
            AppBase.Current.SearchTerm = args.QueryText;
            frame.Navigate(typeof(Views.SearchResult), args.QueryText);
            Window.Current.Content = frame;

            // Ensure the current window is active
            Window.Current.Activate();
        }
Beispiel #30
0
        /// <summary>
        /// Returns the app to the OptionsPage.  Clears data and dispatches the app to the UI thread to insure app stability
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void returnHome_Click(object sender, RoutedEventArgs e)
        {
            var currentApp = (App)App.Current;

            currentApp.CurrentRecogResult = null;
            currentApp.CurrentImageRecog  = null;
            Frame.Navigate(typeof(OptionsPage));

            //dispatch app to the UI thread
            Windows.UI.Core.CoreDispatcher dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;
            await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                      new Windows.UI.Core.DispatchedHandler(
                                          () => Frame.Navigate(typeof(WindowsApp.Views.OptionsPage))));
        }
        public DataViewModelBase(string name, IBandClient bandClient)
        {
            _bandClient = bandClient;

            _name = name;
            _dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;
            _startCmd = new Lazy<ICommand>(() =>
            {
                return new AsyncDelegateCommand<object>(Start, CanStart);
            });
            _stopCmd = new Lazy<ICommand>(() =>
            {
                return new AsyncDelegateCommand<object>(Stop, CanStop);
            });
        }
 public ObservableChessBoard(IChessBoard board, Windows.UI.Core.CoreDispatcher uiDispatcher)
 {
     this.uiDispatcher = uiDispatcher;
     this.board        = board;
     for (int row = 0; row < ChessBoard.Size; row++)
     {
         for (int col = 0; col < ChessBoard.Size; col++)
         {
             if (board.PieceAt(col, row) != null)
             {
                 Add(new ObservableChessPiece(board.PieceAt(col, row), row, col, uiDispatcher));
             }
         }
     }
 }
        public static MockLightingServiceHandler FromJson(string json, Windows.UI.Core.CoreDispatcher dispatcher)
        {
            DataContractJsonSerializer s = new DataContractJsonSerializer(typeof(SerializerClass));

            using (MemoryStream ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(json)))
            {
                var sc   = (SerializerClass)s.ReadObject(ms);
                var mlsh = new MockLightingServiceHandler(sc.Name, sc.Id, sc.IsDimmable, sc.SupportsColor, sc.SupportsTemperature, dispatcher);
                mlsh.LampState_Hue        = sc.Hue;
                mlsh.LampState_Brightness = sc.Brightness;
                mlsh.LampState_Saturation = sc.Saturation;
                mlsh.LampState_ColorTemp  = sc.ColorTemp;
                mlsh.LampState_OnOff      = sc.IsOn;
                return(mlsh);
            }
        }
Beispiel #34
0
        public CollectionViewModel()
        {
            if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;
                Messenger.Default.Register <RefreshDataMessage>(this, RefreshData);
                LoadCollection();
                CurrentPlayerFilter   = SettingsService.Instance.SavedPlayerFilter;
                CurrentPlayTimeFilter = SettingsService.Instance.SavedPlayTimeFilter;
            }

            Collection.CollectionChanged += Collection_CollectionChanged;

            CurrentPlayerFilter.PropertyChanged   += AnyFilterChangedEvent;
            CurrentPlayTimeFilter.PropertyChanged += AnyFilterChangedEvent;
        }
		public MainPage()
        {
			dispatcher = Window.Current.CoreWindow.Dispatcher;

            ToasterFinder toasterFinder = new ToasterFinder();
            toasterFinder.ToasterFound += ToasterFinder_ToasterFound;
            toasterFinder.Start();

            this.InitializeComponent();            

            

			DarknessLevelSlider.IsEnabled = false;
			StartToastButton.IsEnabled = false;
			StopToastButton.IsEnabled = false;
        }
Beispiel #36
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = false;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                // Set the default language
                rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

                rootFrame.NavigationFailed += this.OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;

                dispatcher = Window.Current.Dispatcher;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }

            // Ensure the current window is active
            Window.Current.Activate();

            // Some samples want access to the LaunchActivatedEventArgs.
            this.LaunchCompleted(e);
        }
Beispiel #37
0
        private async void Dispatcher_AcceleratorKeyActivated(Windows.UI.Core.CoreDispatcher sender, Windows.UI.Core.AcceleratorKeyEventArgs args)
        {
            if (args.EventType.ToString().Equals("KeyDown"))
            {
                if (args.VirtualKey == Windows.System.VirtualKey.Shift)
                {
                    C_MAIN_NODE_VIEW.m_ShiftPressed = true;
                }
                if (args.VirtualKey == Windows.System.VirtualKey.Control)
                {
                    m_ControlPressed = true;
                }
                if (args.VirtualKey == Windows.System.VirtualKey.Tab)
                {
                    if (!m_PresetDlgFlag && m_ControlPressed == true)
                    {
                        m_PresetDlgFlag = true;
                        m_PresetDlg.SetList(m_PresetList);
                        try
                        {
                            await m_PresetDlg.ShowAsync();
                        }catch (Exception e)
                        {
                            // m_PresetDlg.Hide();
                        }
                    }
                    else
                    {
                    }
                }
            }

            if (args.EventType.ToString().Equals("KeyUp"))
            {
                if (args.VirtualKey == Windows.System.VirtualKey.Shift)
                {
                    C_MAIN_NODE_VIEW.m_ShiftPressed = false;
                }
                if (args.VirtualKey == Windows.System.VirtualKey.Control)
                {
                    m_ControlPressed = false;
                }
                if (args.VirtualKey == Windows.System.VirtualKey.Escape)
                {
                }
            }
        }
Beispiel #38
0
        public void Unload()
        {
            if (FlickrPersonPhotos != null)
            {
                FlickrPersonPhotos.Clear();
                FlickrPersonPhotos = null;
            }

            if (FavouritePhotos != null)
            {
                FavouritePhotos.Clear();
                FavouritePhotos = null;
            }

            if (FlickrPhotoStreamPhotos != null)
            {
                FlickrPhotoStreamPhotos.Clear();
                FlickrPhotoStreamPhotos = null;
            }

            if (SelectedPhotoComments != null)
            {
                SelectedPhotoComments.Clear();
                SelectedPhotoComments = null;
            }

            SelectedPhoto     = null;
            SelectedPhotoInfo = null;
            SelectedExifInfo  = null;

            if (PublicFavourites != null)
            {
                PublicFavourites.Clear();
                PublicFavourites = null;
            }

            if (PublicPromoted != null)
            {
                PublicPromoted.Clear();
                PublicPromoted = null;
            }

            _dispatcher = null;

            _flickr = null;
        }
Beispiel #39
0
        public MainPage()
        {
            dispatcher = Window.Current.CoreWindow.Dispatcher;

            ToasterFinder toasterFinder = new ToasterFinder();

            toasterFinder.ToasterFound += ToasterFinder_ToasterFound;
            toasterFinder.Start();

            this.InitializeComponent();



            DarknessLevelSlider.IsEnabled = false;
            StartToastButton.IsEnabled    = false;
            StopToastButton.IsEnabled     = false;
        }
        public MainViewModel(Windows.UI.Core.CoreDispatcher dispatcher)
        {
            this.Dispatcher = dispatcher;
            Targets = new ObservableCollection<ShareTarget>();
            model = new Models.ShareTargetsManager();
            model.InitShareTargetStorage();
            model.PeerDiscoveryComplete += PeerDiscoveryComplete;
            model.PeerDiscovered += PeerDiscovered;

            SharingDialogModel = new SharingDialogViewModel(Dispatcher);

            AddTarget = new DelegateCommand(AddTargetExecute);
            EditTarget = new DelegateCommand(EditTargetExecute, CanEditTargetExecute);
            DeleteTarget = new DelegateCommand(DeleteTargetExecute, CanDeleteTargetExecute);
            ShowAddTarget = new DelegateCommand(ShowAddTargetExecute);
            CancelAddTarget = new DelegateCommand(CancelAddTargetExecute);
            RefreshTargets = new DelegateCommand(PerformPeerDiscovery);
        }
 public MockOnOffSwitchDevice(string name, string id, bool isOn, Windows.UI.Core.CoreDispatcher dispatcher) :
     base(name, "MockDevices Inc", "Mock Switch", "1", id, "")
 {
     this.dispatcher = dispatcher;
     Icon = new AdapterIcon(new System.Uri("ms-appx:///Icons/Switch.png"));
     _interfaceOnOff = CreateOnOffInterface(isOn);
     _interfaceOn = CreateOnInterface(isOn);
     _interfaceOff = CreateOffInterface(!isOn);
     _interfaceRemoteControl = CreateRemoteControllabilityInterface(true);
     AdapterBusObject abo = new AdapterBusObject("org/alljoyn/SmartSpaces/Operation/Switch");
     abo.Interfaces.Add(_interfaceOnOff);
     abo.Interfaces.Add(_interfaceOn);
     abo.Interfaces.Add(_interfaceOff);
     abo.Interfaces.Add(_interfaceRemoteControl);
     this.BusObjects.Add(abo);
     CreateEmitSignalChangedSignal();
     _onOff = isOn;
 }
Beispiel #42
0
        //public ObservableCollection<clsDevType> DevTypes = new ObservableCollection<clsDevType>();

        async void WatchDevices_Click(object sender, RoutedEventArgs eventArgs)
        {
            if (watcher != null)
            {
                watcher = null;
            }
            count = 0; 
            isEnumerationComplete = false;
            StopStatus = null;
            //DeviceInterfacesOutputList.Items.Clear();

            try
            {
                dispatcher = Window.Current.CoreWindow.Dispatcher;
                watcher = DeviceInformation.CreateWatcher();
                // Add event handlers
                watcher.Added += watcher_Added;
                watcher.Removed += watcher_Removed;
                watcher.Updated += watcher_Updated;
                watcher.EnumerationCompleted += watcher_EnumerationCompleted;
                watcher.Stopped += watcher_Stopped;
                watcher.Start();
                OutputText.Text = "Enumeration started.";

                this.btnWatchDevices.IsEnabled = false;
                this.btnStop.IsEnabled = !(this.btnWatchDevices.IsEnabled);


            }
            catch (ArgumentException)
            {
                //The ArgumentException gets thrown by FindAllAsync when the GUID isn't formatted properly
                //The only reason we're catching it here is because the user is allowed to enter GUIDs without validation
                //In normal usage of the API, this exception handling probably wouldn't be necessary when using known-good GUIDs 
                OutputText.Text = "Caught ArgumentException. Failed to create watcher.";
            }
        }
Beispiel #43
0
        protected override void OnSearchActivated(SearchActivatedEventArgs args)
        {

            base.OnSearchActivated(args);
            var previousContent = Window.Current.Content;
            var frame = previousContent as Frame ?? new Frame();

            Dispatcher = Window.Current.Dispatcher;
            AppBase.Current.SearchTerm = args.QueryText;
            frame.Navigate(typeof(Views.SearchResult), args.QueryText);
            Window.Current.Content = frame;

            // Ensure the current window is active
            Window.Current.Activate();
        }
        public void Unload()
        {
            if (FlickrPersonPhotos != null) { 
                FlickrPersonPhotos.Clear();
                FlickrPersonPhotos = null;
            }

            if (FavouritePhotos != null)
            {
                FavouritePhotos.Clear();
                FavouritePhotos = null;
            }

            if (FlickrPhotoStreamPhotos != null) { 
                FlickrPhotoStreamPhotos.Clear();
                FlickrPhotoStreamPhotos = null;
            }

            if (SelectedPhotoComments != null) { 
                SelectedPhotoComments.Clear();
                SelectedPhotoComments = null;
            }

            SelectedPhoto = null;
            SelectedPhotoInfo = null;
            SelectedExifInfo = null;

            if (PublicFavourites != null) { 
                PublicFavourites.Clear();
                PublicFavourites = null;
            }

            if (PublicPromoted != null) { 
                PublicPromoted.Clear();
                PublicPromoted = null;
            }

            _dispatcher = null;
            
            _flickr = null;
        }
Beispiel #45
0
        protected override void OnWindowCreated(WindowCreatedEventArgs args)
        {
            _dispatcher = args.Window.Dispatcher;

            base.OnWindowCreated(args);
        }
 public ViewModelBase()
 {
     var window = Windows.UI.Core.CoreWindow.GetForCurrentThread();
     if (window != null)
         _dispatcher = window.Dispatcher;
 }
Beispiel #47
0
 public MainPage()
 {
     this.InitializeComponent();
     dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="context">The PrinterExtensionContext from the app.</param>
 public PrintHelperClass(Object context)
 {
     this.context = new PrinterExtensionContext(context);
     printerQueue = this.context.Queue;
     dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;
 }
Beispiel #49
0
        protected async override void OnSearchActivated(Windows.ApplicationModel.Activation.SearchActivatedEventArgs args)
        {
            // TODO: Register the Windows.ApplicationModel.Search.SearchPane.GetForCurrentView().QuerySubmitted
            // event in OnWindowCreated to speed up searches once the application is already running

            // If the Window isn't already using Frame navigation, insert our own Frame
            var previousContent = Window.Current.Content;
            var frame = previousContent as Frame;

            // If the app does not contain a top-level frame, it is possible that this 
            // is the initial launch of the app. Typically this method and OnLaunched 
            // in App.xaml.cs can call a common method.
            if (frame == null)
            {
                // Create a Frame to act as the navigation context and associate it with
                // a SuspensionManager key
                frame = new Frame();
                Common.SuspensionManager.RegisterFrame(frame, "AppFrame");

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate
                    try
                    {
                        await Common.SuspensionManager.RestoreAsync();
                    }
                    catch (Common.SuspensionManagerException)
                    {
                        //Something went wrong restoring state.
                        //Assume there is no state and continue
                    }
                }
            }

            dispatcher = Windows.UI.Xaml.Window.Current.Dispatcher;
            AppBase.Current.SearchTerm = args.QueryText;
            frame.Navigate(typeof(Views.SearchResult), args.QueryText);
            Window.Current.Content = frame;

            // Ensure the current window is active
            Window.Current.Activate();
        }