Beispiel #1
0
        private void toolStripButton16_Click(object sender, EventArgs e)
        {
            Image   backgroundimage = this.hubTile1.ImageSource;
            Label   slidelabel      = new Label();
            HubTile hub             = new HubTile();

            this.panel2.Controls.Add(slidelabel);
            slidelabel.Text      = slidenumber.ToString();
            slidelabel.ForeColor = ColorTranslator.FromHtml("#d24726");

            slidelabel.Font     = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.World, ((byte)(0)));
            slidelabel.AutoSize = true;
            slidenumber++;
            this.panel2.Controls.Add(hub);
            hub.Location        = new Point(x, y);
            slidelabel.Location = new Point(x - 20, y);
            x = 28;
            y = y + 108;

            hub.Size = new Size(165, 100);
            foreach (Control ctrl in this.panel2.Controls)
            {
                if (ctrl is HubTile)
                {
                    (ctrl as HubTile).ImageSource = backgroundimage;
                }
            }
        }
Beispiel #2
0
        private void HubTile_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            Uri     page;
            HubTile tile = (HubTile)sender;

            switch (tile.Name)
            {
            case "BrewHouseTile":
                page = new Uri("/Views/PivotBrewHouse.xaml", UriKind.RelativeOrAbsolute);
                break;

            case "HopsTile":
                page = new Uri("/Views/PivotHops.xaml", UriKind.RelativeOrAbsolute);
                break;

            case "ConvertersTile":
                page = new Uri("/Views/PivotConverters.xaml", UriKind.RelativeOrAbsolute);
                break;

            case "MaltsTile":
                page = new Uri("/Views/PivotMalts.xaml", UriKind.RelativeOrAbsolute);
                break;

            case "SettingsTile":
                page = new Uri("/Views/PivotSettings.xaml", UriKind.RelativeOrAbsolute);
                break;

            default:
                page = new Uri("");
                break;
            }

            NavigationService.Navigate(page);
        }
Beispiel #3
0
        private void CreateLiveTile(HubTile hubtile)
        {
            StandardTileData LiveTile = new StandardTileData
            {
                BackgroundImage = ((System.Windows.Media.Imaging.BitmapImage)hubtile.Source).UriSource,
                Title           = hubtile.Title,
                BackTitle       = hubtile.Title,
                BackContent     = hubtile.Message
            };
            ShellTile Tile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("DefaultTitle=" + LiveTile.Title));

            if (Tile == null)
            {
                try
                {
                    ShellTile.Create(new Uri("/AddPage.xaml?category=" + hubtile.Title, UriKind.Relative), LiveTile);
                }
                catch (Exception)
                {
                    MessageBox.Show("I prefer not to be pinned");
                }
            }
            else
            {
                MessageBox.Show("The tile is already pinned");
            }
        }
Beispiel #4
0
        private void hub_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            HubTile hubTileRandomTip = (HubTile)sender;
            String  title            = hubTileRandomTip.Title;
            String  encryptedTitle   = HttpUtility.HtmlEncode(title);

            NavigationService.Navigate(new Uri("/Tips.xaml?Title=" + encryptedTitle, UriKind.Relative));
        }
Beispiel #5
0
 void cleanUp()
 {
     foreach (HyperlinkButton child in pnlMain.Children)
     {
         HubTile hub = (HubTile)child.Content;
         hub.Tap -= content_Tap;
     }
     pnlMain.Children.Clear();
 }
        private void ShowWebNew(object sender, System.Windows.Input.GestureEventArgs e)
        {
            HubTile iHubTile = sender as HubTile;

            //          WebBrowserTask webTask = new WebBrowserTask();
            //  webTask.Uri = new Uri(iHubTile.Tag.ToString());
//            webTask.Show();
            NavigationService.Navigate(new Uri("/ShowOnePage.xaml?URL=" + iHubTile.Tag.ToString(), UriKind.Relative));
        }
        private void TopBarBtn_Click(object sender, RoutedEventArgs e)
        {
            Button b     = sender as Button;
            var    param = b.CommandParameter as string;

            var type = param == "SearchMeds" ? typeof(SearchMedications) :
                       param == "Profile" ? typeof(MyProfile) :
                       param == "Studies" ? typeof(ResearchStudiesView) :
                       param == "MyStudies" ? typeof(MyStudies) :
                       param == "Education" ? typeof(EducationalMaterial) :
                       param == "Alerts" ? typeof(SafetyAlerts) : null
            ;

            if (type == null)
            {
                HubTile tile;
                if (param == "Health")
                {
                    tile =
                        new HubTile
                    {
                        Title    = "My Health Record",
                        Subtitle = "Health Record",
                        Image    = "/Assets/myhealthrecordIcon.png",
                        Width    = 225,
                        Height   = 200,
                        ColSpan  = 1,
                        URL      = "https://account.healthvault.com/signin"
                    }
                }
                ;
                else
                {
                    tile =
                        new HubTile
                    {
                        Title    = "Patient Communities",
                        Subtitle = "Communities",
                        Image    = "/Assets/patientcommunitiesIcon.png",
                        Width    = 225,
                        Height   = 200,

                        ColSpan = 1,
                        URL     = "http://www.centerwatch.com/health-resources/"
                    }
                };

                frame1.Navigate(typeof(WebPageView), tile);
            }
            else
            {
                frame1.Navigate(type);
            }
            TopAppBar.IsOpen = false;
        }
        public Friend_Photo(PublisherServiceClient _client)
        {
            InitializeComponent();
            hubTile = new HubTile();
            this.grid_Content.Children.Add(hubTile);
            hubTile.DisplayNotification = true;

            // hubTile.Background = new SolidColorBrush(new Color() {A=255, });
            // client = _client;
            //  client.GetImageByItemIdCompleted+=new EventHandler<GetImageByItemIdCompletedEventArgs>(client_GetImageByItemIdCompleted);
        }
Beispiel #9
0
        // Called when a hubtile is loaded. We disable loading message and set it as visible
        private void HubTile_Loaded(object sender, RoutedEventArgs e)
        {
            if (LoadingMessage.Visibility == Visibility.Visible)
            {
                GlobalLoading.Instance.IsLoading = false;
                LoadingMessage.Visibility        = Visibility.Collapsed;
            }

            HubTile currentTile = sender as HubTile;

            currentTile.Visibility = Visibility.Visible;
        }
        void UpdateItems(System.Windows.Controls.Grid grid)
        {
            grid.Children.Clear();

            grid.RowDefinitions.Clear();

            var x = 0;
            var y = 0;

            foreach (Page target in Element.Targets)
            {
                if (x > 1)
                {
                    x = 0;
                    y++;
                }

                if (x == 0)
                {
                    grid.RowDefinitions.Add(new System.Windows.Controls.RowDefinition());
                }

                var hubTile = new HubTile {
                    Title = target.Title, Source = new BitmapImage(new Uri(target.Icon, UriKind.Relative)), Margin = new System.Windows.Thickness(0, 0, Spacing, Spacing)
                };

                if (target.BackgroundColor != Color.Default)
                {
                    hubTile.Background = target.BackgroundColor.ToBrush();
                }

                Page tmp = target;
                hubTile.Tap += (sender, args) => Element.SendTargetSelected(tmp);

                hubTile.SetValue(System.Windows.Controls.Grid.RowProperty, y);
                hubTile.SetValue(System.Windows.Controls.Grid.ColumnProperty, x);
                hubTile.Size = GetSize();

                var weakRef = new WeakReference(hubTile);
                SizeChanged += (sender, args) =>
                {
                    var hTile = (HubTile)weakRef.Target;
                    if (hTile != null)
                    {
                        hTile.Size = GetSize();
                    }
                    ((IVisualElementController)Element).NativeSizeChanged();
                };

                x++;
                grid.Children.Add(hubTile);
            }
        }
Beispiel #11
0
        //except means tiles without animation (when we click on one tile the rest should go away but this clicked should stay)
        private void animateControls(HubTile tile, bool leaveAnimation = true)
        {
            Storyboard anim = new Storyboard();

            for (int index = 0; index < pnlMain.Children.Count; index++)
            {
                HyperlinkButton button = (HyperlinkButton)pnlMain.Children[index];
                if (tile == null || tile != button.Content)
                {//add to all button except this clicked
                    addButtonAnimation(button, anim, index, leaveAnimation);
                }
            }
            anim.Begin();
        }
Beispiel #12
0
        private void addButtonAnimation(HyperlinkButton link, Storyboard anim, int currentIndex, bool leaveAnimation)
        {
            HubTile hub      = (HubTile)link.Content;
            var     leftSide = currentIndex % 2 == 0;

            var trans = hub.RenderTransform;
            var x     = new DoubleAnimation();

            x.Duration = new Duration(TimeSpan.FromSeconds(durationTime));
            //x.From = !leftSide?-80:80;
            if (leaveAnimation)
            {
                x.From = 0;
                x.To   = leftSide ? -500 : 500;
            }
            else
            {
                x.From = leftSide ? -500 : 500;
                x.To   = 0;
            }



            anim.Children.Add(x);
            Storyboard.SetTarget(x, trans);
            Storyboard.SetTargetProperty(x, new PropertyPath("X"));

            //for first and last row add also vertical animation
            if (currentIndex == 0 || currentIndex == 1 || currentIndex == pnlMain.Children.Count - 1 || currentIndex == pnlMain.Children.Count - 2)
            {
                bool isFirstRow = currentIndex == 0 || currentIndex == 1;
                var  y          = new DoubleAnimation();
                y.Duration = new Duration(TimeSpan.FromSeconds(durationTime));
                if (leaveAnimation)
                {
                    y.From = 0;
                    y.To   = isFirstRow ? -500 : 500;
                }
                else
                {
                    y.From = isFirstRow ? -500 : 500;
                    y.To   = 0;
                }

                anim.Children.Add(y);
                Storyboard.SetTarget(y, trans);
                Storyboard.SetTargetProperty(y, new PropertyPath("Y"));
            }
        }
Beispiel #13
0
        private void toolStripButton20_Click(object sender, EventArgs e)
        {
            Image   backgroundimage = this.hubTile1.ImageSource;
            HubTile hub             = new HubTile();

            this.panel2.Controls.Add(hub);
            hub.Location = new Point(x, y);
            x            = 15;
            y            = y + 108;
            hub.Size     = new Size(163, 100);
            foreach (HubTile ctrl in this.panel2.Controls)
            {
                ctrl.ImageSource = backgroundimage;
            }
        }
Beispiel #14
0
 void tileButtonClick(HubTile tile, object tag, bool forceNew)
 {
     try
     {
         if (isOpening)
         {
             return;
         }
         isOpening = true;
         openEntry(tile, tag, forceNew);
     }
     catch (Exception)
     {
         isOpening = false;
         BAMessageBox.ShowError(ApplicationStrings.ErrUnhandledErrorOccured);
     }
 }
        private void OneCity_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            for (int i = 0; i <= MaxNewsNamesIndex; i++)
            {
                if (i == OneCity.SelectedIndex)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        HubTile iHubtile = (HubTile)this.FindName(NewsNames[i] + j.ToString());
                        VisualStateManager.GoToState(iHubtile, "Flipped", true);
                    }

//                    HubTileService.UnfreezeGroup(NewsNames[i]);
                }
            }
            //               else
            //                 HubTileService.FreezeGroup(NewsNames[i]);
        }
Beispiel #16
0
        private void ItemView_ItemClick(object sender, ItemClickEventArgs e)
        {
            HubTile tile = (HubTile)e.ClickedItem;
            Type    view = tile.View == "SearchMedications" ? typeof(SearchMedications) :
                           tile.View == "MyProfile" ? typeof(MyProfile) :
                           tile.View == "ResearchStudies" ? typeof(ResearchStudiesView) :
                           tile.View == "MyStudies" ? typeof(MyStudies) :
                           tile.View == "SafetyAlerts" ? typeof(SafetyAlerts) :
                           tile.View == "EducationalMaterial" ? typeof(EducationalMaterial) :
                           tile.View == "WebPageView" ? typeof(WebPageView) :
                           typeof(HubPage);



            DataService.CreateUserAccessLog(CurrentUser, "Navigation", tile.View);

            this.Frame.Navigate(view, e.ClickedItem);
        }
Beispiel #17
0
        void openEntry(HubTile tile, object tag, bool forceNew)
        {
            if (tile != null)
            {
                animateControls(tile);
            }

            PrepareTrainingDay();
            if (tag is EntryObjectDTO && !forceNew)
            {//open existing entry
                ApplicationState.Current.CurrentEntryId = new LocalObjectKey((EntryObjectDTO)tag);
            }
            else
            {
                addNewEntry(tag);
            }

            GoToPage(tag, this.GetParent <PhoneApplicationPage>());
        }
Beispiel #18
0
        HyperlinkButton addButton(Type entryObjectType, EntryObjectDTO existingObject)
        {
            HyperlinkButton link = new HyperlinkButton();

            link.Style = (Style)Application.Current.Resources["EmptyButtonStyle"];
            HubTile content = new HubTile();

            content.Tag  = link.Tag = existingObject;
            link.Content = content;
            if (prepareButton(link, entryObjectType))
            {
                TranslateTransform transform = new TranslateTransform();
                content.RenderTransform = transform;
                pnlMain.Children.Add(link);
                content.Tap += content_Tap;

                return(link);
            }
            return(null);
        }
Beispiel #19
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (String.IsNullOrEmpty(Settings.CachedAuthenticationToken))
            {
                NavigationService.Navigate(new Uri("/SettingsPage.xaml", UriKind.Relative));
                return;
            }

            if (e.NavigationMode == NavigationMode.Back)
            {
                return;
            }

            User.Text = "Hello " + Settings.Username;

            client =
                new SpeechServiceClient(
                    GetBinding(),
                    GetEndpointAddress("Speech"));

            client.RecognizeCompleted +=
                (o1, e1) =>
            {
                HideProgress();

                if (e1.Error != null)
                {
                    if (e1.Error.GetType() == typeof(FaultException <AuthenticationFault>))
                    {
                        GetAuthenticationToken(
                            new Action(
                                () =>
                        {
                            client.RecognizeAsync(
                                Settings.CachedAuthenticationToken,
                                encodedFrames.ToArray(),
                                false,
                                null,
                                null);
                        }
                                ));
                    }
                    else
                    {
                        MessageBox.Show(e1.Error.Message);
                    }

                    return;
                }

                if (e1.Result.AnswerSpeech != null && e1.Result.AnswerSpeech.Length > 0)
                {
                    // Play the audio in a new thread so the UI can update.
                    new Thread(
                        () =>
                    {
                        byte[] speechBuffer = Speex.DecodeAllFrames(e1.Result.AnswerSpeech);
                        //SoundEffect sound = new SoundEffect(speechBuffer, 24000, AudioChannels.Mono);//microphone.SampleRate, AudioChannels.Mono);
                        //soundInstance = sound.CreateInstance();
                        //soundInstance.Play();
                    }).Start();
                }

                // TODO:
                MessageBox.Show(String.Format("I am {0}% confident you said \"{1}\". To which I reply \"{2}\".", e1.Result.Confidence * 100, e1.Result.Command, e1.Result.AnswerText));
            };

            int counter = 0;

            foreach (var endpoint in Settings.Endpoints)
            {
                if (endpoint.Key == "Speech" || endpoint.Key == "Recipes")
                {
                    continue;
                }

                HubTile tile =
                    new HubTile()
                {
                    Margin = new Thickness(12, 12, 0, 0),
                    Source = new BitmapImage(new Uri("/Images/" + endpoint.Key + ".png", UriKind.Relative)),
                    Name   = endpoint.Key,
                    //Title = endpoint.Key,
                    IsFrozen = true,
                    //Background = (SolidColorBrush)Resources["PhoneAccentBrush"],
                    //Message = "Message",
                    //DisplayNotification = true,
                    //Notification = "Notification",
                };
                tile.SetValue(Grid.ColumnProperty, counter % 2);
                tile.SetValue(Grid.RowProperty, counter / 2);

                tile.Tap +=
                    (o1, e1) =>
                {
                    NavigationService.Navigate(new Uri("/" + ((HubTile)o1).Name + "Page.xaml", UriKind.Relative));
                };

                tile.MouseLeftButtonDown +=
                    (o1, e1) =>
                {
                    System.Windows.Point tmpPoint = e1.GetPosition(null);
                    contextMenuSelectedHubTile = null;
                    List <UIElement> oControls = (List <UIElement>)VisualTreeHelper.FindElementsInHostCoordinates(tmpPoint, this);
                    foreach (UIElement ctrl in oControls)
                    {
                        if (ctrl is HubTile)
                        {
                            contextMenuSelectedHubTile = (HubTile)ctrl;
                            break;
                        }
                    }
                };

                TileGrid.Children.Add(tile);

                counter++;
            }

            HideProgress();
        }
        void ParseRSSAndBindData(string RSSString, string Title)
        {
            try
            {
                XElement iNews = XElement.Parse(RSSString);

                var postList =
                    from tweet in iNews.Descendants("item")
                    select new PostMessage
                {
                    title       = tweet.Element("title").Value,
                    mainImage   = allFunc.GetImageFromPostContents(tweet.Element("description").Value),
                    description = Regex.Replace(tweet.Element("description").Value, "<.*?>", String.Empty),
                    pubDate     = Convert.ToDateTime(tweet.Element("pubDate").Value).ToString(),
                    link        = tweet.Element("link").Value
                };

                PanoramaItem iPanoramaItem = new PanoramaItem();
                iPanoramaItem.Header      = Title;
                iPanoramaItem.Orientation = System.Windows.Controls.Orientation.Horizontal;
                ScrollViewer iScrollViewer = new ScrollViewer();

                StackPanel mStackPanel = new StackPanel();
                mStackPanel.Margin            = new Thickness(0, 4, 16, 0);
                mStackPanel.Orientation       = System.Windows.Controls.Orientation.Vertical;
                mStackPanel.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                SolidColorBrush backColor        = new SolidColorBrush(Color.FromArgb(0xFF, 0xDF, 0xD6, 0xAB));
                SolidColorBrush foreColor        = new SolidColorBrush(Color.FromArgb(0xFF, 0x3A, 0x3A, 0x3A));
                StackPanel      firstStackPanel  = new StackPanel();
                StackPanel      secondStackPanel = new StackPanel();
                StackPanel      thirdStackPanel  = new StackPanel();

                firstStackPanel.Orientation  = System.Windows.Controls.Orientation.Horizontal;
                secondStackPanel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                secondStackPanel.Margin      = new Thickness(0, 12, 0, 0);
                thirdStackPanel.Orientation  = System.Windows.Controls.Orientation.Horizontal;
                thirdStackPanel.Margin       = new Thickness(0, 12, 0, 0);

                int i = 0;
                foreach (var iNew in postList)
                {
                    HubTile iHubTile = new HubTile();
                    iHubTile.Margin       = new Thickness(12, 0, 0, 0);
                    iHubTile.Title        = iNew.pubDate.ToString(); // Title;
                    iHubTile.Message      = iNew.title;
                    iHubTile.Notification = iNew.title;
                    iHubTile.Source       = new BitmapImage(new Uri(iNew.mainImage, UriKind.Absolute));
                    iHubTile.Background   = backColor;
                    iHubTile.Foreground   = foreColor;
                    iHubTile.Tag          = iNew.link;
                    iHubTile.Tap         += ShowWebNew;
                    iHubTile.GroupTag     = Title;
                    iHubTile.Name         = Title + i.ToString();
                    iHubTile.Size         = TileSize.Medium;

                    if (i > 6)
                    {
                        thirdStackPanel.Children.Add(iHubTile);
                    }
                    else if (i > 3)
                    {
                        secondStackPanel.Children.Add(iHubTile);
                    }
                    else
                    {
                        HubTileService.FreezeHubTile(iHubTile);
                        firstStackPanel.Children.Add(iHubTile);
                    }
                    i++;
                }
                mStackPanel.Children.Add(firstStackPanel);
                mStackPanel.Children.Add(secondStackPanel);
                mStackPanel.Children.Add(thirdStackPanel);
                iScrollViewer.Content = mStackPanel;
                iPanoramaItem.Content = iScrollViewer;
                OneCity.Items.Add(iPanoramaItem);
            }
            catch
            {
            }
        }
        public CamerasPage()
        {
            InitializeComponent();

            client =
                new CameraServiceClient(
                    GetBinding(),
                    GetEndpointAddress("Cameras"));

            client.ListCamerasCompleted +=
                (o1, e1) =>
            {
                HideProgress();

                if (e1.Error != null)
                {
                    if (e1.Error.GetType() == typeof(FaultException <AuthenticationFault>))
                    {
                        GetAuthenticationToken(
                            new Action(
                                () =>
                        {
                            client.ListCamerasAsync(Settings.CachedAuthenticationToken);
                        }
                                ));
                    }
                    else
                    {
                        MessageTextBlock.Text = "Error retrieving camera list.";
                        MessageBox.Show(e1.Error.Message);
                    }

                    return;
                }

                if (e1.Result == null || e1.Result.Length == 0)
                {
                    MessageTextBlock.Text = "You have not set up any cameras. Press the add button to add a camera to the system.";
                }
                else
                {
                    MessageTextBlock.Visibility = System.Windows.Visibility.Collapsed;
                }

                int counter = 0;
                foreach (var a in e1.Result)
                {
                    HubTile tile =
                        new HubTile()
                    {
                        Title = a.Location,
                        Tag   = String.Format(
                            CultureInfo.InvariantCulture,
                            "?location={0}&mjpegurl={1}&username={2}&password={3}",
                            a.Location,
                            HttpUtility.UrlEncode(a.MjpegUrl),
                            a.Username,
                            a.Password),
                        Source =
                            new BitmapImage(
                                new Uri(
                                    a.ImageUrl.Insert(
                                        7,
                                        String.Format(
                                            CultureInfo.InvariantCulture,
                                            "{0}:{1}@",
                                            a.Username,
                                            a.Password)),
                                    UriKind.Absolute)),
                        Margin = new Thickness(12, 12, 0, 0),
                    };

                    tile.SetValue(Grid.ColumnProperty, counter % 2);
                    tile.SetValue(Grid.RowProperty, counter / 2);

                    tile.Tap +=
                        (o2, e2) =>
                    {
                        NavigationService.Navigate(new Uri("/SingleCameraPage.xaml" + (((HubTile)o2).Tag.ToString()), UriKind.Relative));
                    };

                    CameraGrid.Children.Add(tile);

                    counter++;
                }
            };
        }
Beispiel #22
0
        private void HubTile_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            HubTile ht = (HubTile)sender;

            NavigationService.Navigate(new Uri("/AddPage.xaml?category=" + ht.Title, UriKind.Relative));
        }