Beispiel #1
0
        private Border NewProg(Programme prg)
        {
            MyProgramme myp = Translate(prg);
            TextBlock   tb  = new TextBlock()
            {
                Text = myp.title, Width = Math.Round((myp.Width > 1?myp.Width - 1:myp.Width), 0), FontSize = 9, Tag = myp
            };

            myp.Parent = tb;
            if (myp.start < DateTime.Now && myp.stop > DateTime.Now)
            {
                tb.Width = Math.Round(new TimeSpan(myp.stop.Ticks - DateTime.Now.Ticks).TotalMinutes, 0) * 6;
                tb.Width = Math.Round((tb.Width > 1 ? tb.Width - 1 : tb.Width), 0);
            }
            tb.HorizontalAlignment = HorizontalAlignment.Stretch;
            tb.VerticalAlignment   = VerticalAlignment.Stretch;
            tb.TextAlignment       = TextAlignment.Center;
            Border bo = inBorder(tb);

            if (myp.start <= DateTime.Now && DateTime.Now < myp.stop)
            {
                tb.FontWeight = FontWeights.Bold;
            }
            if (myp.stop < DateTime.Now)
            {
                bo.Style = sOld;
            }
            tb.MouseLeave += (x, z) =>
            {
                if (myp.stop < DateTime.Now)
                {
                    bo.Style = sOld;
                }
                else
                {
                    bo.Style = sOrg;
                }
            };
            tb.MouseEnter += (x, z) =>
            {
                bo.Style          = sAlt;
                canvas.Visibility = Visibility.Collapsed;
            };
            tb.MouseLeftButtonDown += (c, d) =>
            {
                showCanvas(d.GetPosition(LayoutRoot));
                info.Text = myp.start.ToString("yyyy-MM-dd HH:mm") + "-" + myp.stop.ToString("HH:mm") + "\r" +
                            myp.title + (!string.IsNullOrEmpty(myp.subtitle) ? " - " + myp.subtitle : "") +
                            "\r" + myp.desc;
            };
            return(bo);
        }
Beispiel #2
0
        private void showChannel(GetProgrammesCompletedEventArgs b)
        {
            programmes.Children.Clear();

            programmes.Orientation = Orientation.Vertical;
            foreach (Programme prg in b.Result.programmes)
            {
                MyProgramme myp = Translate(prg);
                TextBlock   tb  = new TextBlock()
                {
                    Text = myp.start.ToString("HH:mm") + "-" + myp.stop.ToString("HH:mm") + " " + myp.title, Width = 400, FontSize = 9, Tag = myp
                };
                myp.Parent = tb;
                Border bo = inBorder(tb);
                if (myp.start <= DateTime.Now && DateTime.Now < myp.stop)
                {
                    tb.FontWeight = FontWeights.Bold;
                }
                if (myp.stop < DateTime.Now)
                {
                    bo.Style = sOld;
                }
                tb.MouseLeave += (x, z) =>
                {
                    if (myp.stop < DateTime.Now)
                    {
                        bo.Style = sOld;
                    }
                    else
                    {
                        bo.Style = sOrg;
                    }
                };
                tb.MouseEnter += (x, z) =>
                {
                    bo.Style          = sAlt;
                    canvas.Visibility = Visibility.Collapsed;
                    showCanvas(z.GetPosition(LayoutRoot));
                    info.Text = myp.start.ToString("yyyy-MM-dd HH:mm") + "-" + myp.stop.ToString("HH:mm") + "\r" +
                                myp.title + (!string.IsNullOrEmpty(myp.subtitle) ? " - " + myp.subtitle : "") +
                                "\r" + myp.desc;
                };
                programmes.Children.Add(bo);
            }
        }
Beispiel #3
0
        private void showMain(GetProgrammesCompletedEventArgs b)
        {
            programmes.Children.Clear();

            programmes.Orientation = Orientation.Horizontal;
            int imin = 9999;

            /*
             * foreach (string chn in b.Result.programmes.Select(x=>x.channel).Distinct())
             * {
             *  int l = b.Result.programmes.Count(x => x.channel == chn);
             *  imin = Math.Min(imin, l);
             * }
             */
            List <StackPanel> sps = new List <StackPanel>();

            foreach (string chn in b.Result.programmes.OrderBy(x => FixToNum(x.channel)).Select(x => x.channel).Distinct())
            {
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Vertical;
                sp.Margin      = new Thickness(10);

                Image img = new Image();
                ImageSourceConverter isc         = new ImageSourceConverter();
                ImageSource          imagesource = isc.ConvertFromString("images/" + chn + ".png") as ImageSource;
                img.Source = imagesource;
                img.HorizontalAlignment = HorizontalAlignment.Left;
                img.MaxHeight           = 44;
                Border bimg = inBorder(img);
                bimg.BorderThickness = new Thickness(1);
                sp.Children.Add(bimg);
                var list = b.Result.programmes.Where(x => x.channel.Equals(chn)).OrderBy(x => x.start);
                int icnt = 0;

                foreach (Programme prg in list.Where(x => !x.title.Contains("Sändningsuppehåll")))
                {
                    MyProgramme myp = Translate(prg);

                    TextBlock tb = new TextBlock()
                    {
                        Text = myp.start.ToString("HH:mm") + " " + myp.title, Width = 200, FontFamily = new FontFamily("Verdana"), FontSize = 12, Tag = myp
                    };
                    myp.Parent = tb;

                    Border bo = inBorder(tb);
                    bo.BorderThickness = new Thickness(1, 0, 1, 1);

                    if (myp.start <= DateTime.Now && DateTime.Now < myp.stop)
                    {
                        tb.FontWeight = FontWeights.Bold;
                    }
                    if (myp.stop < DateTime.Now)
                    {
                        bo.Style = sOld;
                    }
                    tb.MouseLeave += (x, z) =>
                    {
                        if (myp.stop < DateTime.Now)
                        {
                            bo.Style = sOld;
                        }
                        else
                        {
                            bo.Style = sOrg;
                        }
                    };
                    tb.MouseEnter += (x, z) =>
                    {
                        bo.Style          = sAlt;
                        canvas.Visibility = Visibility.Collapsed;
                        showCanvas(z.GetPosition(LayoutRoot));

                        info.Text = myp.start.ToString("yyyy-MM-dd HH:mm") + "-" + myp.stop.ToString("HH:mm") + "\r" +
                                    myp.title + (!string.IsNullOrEmpty(myp.subtitle) ? " - " + myp.subtitle : "") +
                                    "\r" + myp.desc;
                    };
                    icnt++;

                    if (icnt == list.Count() || icnt == imin)
                    {
                        bo.BorderThickness = new Thickness(1, 0, 1, 1);
                    }
                    AddToSp(sp, bo);
                    if (icnt == imin)
                    {
                        break;
                    }
                }
                sps.Add(sp);
            }
            programmes.Orientation = Orientation.Vertical;
            List <StackPanel> spvs      = new List <StackPanel>();
            string            strPerRow = (programmes.ActualWidth / 220).ToString();
            int    numperrows           = int.Parse(strPerRow.Contains(",")?strPerRow.Substring(0, strPerRow.IndexOf(",")):strPerRow.Contains(".")?strPerRow.Substring(0, strPerRow.IndexOf(".")):strPerRow);
            double cnt = sps.Count;
            //int sqrt = int.Parse(Math.Round((Math.Sqrt(cnt)+1), 0).ToString());
            int sqrt = int.Parse(Math.Round((cnt / numperrows), 0).ToString());

            for (int ix = 0; ix < sqrt; ix++)
            {
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                sp.Margin      = new Thickness(0);
                spvs.Add(sp);
            }
            int ispicnt = 0;
            int ispvcnt = 0;

            foreach (StackPanel spi in sps)
            {
                if (ispicnt > 0 && ispicnt >= numperrows) //ispicnt % sqrt == 0)
                {
                    ispicnt = 0;
                    ispvcnt++;
                }
                StackPanel spv = spvs[ispvcnt];
                spv.Children.Add(spi);
                ispicnt++;
            }

            foreach (StackPanel spv in spvs)
            {
                programmes.Children.Add(spv);
            }
            programmes.HorizontalAlignment = HorizontalAlignment.Stretch;
            programmes.VerticalAlignment   = VerticalAlignment.Stretch;
        }
Beispiel #4
0
        private void showNow(GetProgrammesCompletedEventArgs b)
        {
            programmes.Children.Clear();

            programmes.Orientation = Orientation.Vertical;
            foreach (Programme prg in b.Result.programmes.OrderBy(x => FixToNum(x.channel)))
            {
                MyProgramme myp = Translate(prg);
                if (myp.start <= DateTime.Now && DateTime.Now < myp.stop)
                {
                    StackPanel sp = new StackPanel();
                    sp.Orientation = Orientation.Horizontal;
                    sp.Margin      = new Thickness(0);

                    Image img = new Image();
                    ImageSourceConverter isc         = new ImageSourceConverter();
                    ImageSource          imagesource = isc.ConvertFromString("images/" + prg.channel + ".png") as ImageSource;
                    img.Source    = imagesource;
                    img.MaxHeight = 44;

                    Border boimg = inBorder(img);
                    boimg.MinWidth = 44;
                    sp.Children.Add(boimg);

                    /*
                     * Border bochn = inBorder(new TextBlock() { Text = myp.channelname, Width = 100 });
                     * sp.Children.Add(bochn);
                     */

                    TextBlock tb = new TextBlock()
                    {
                        Text = myp.start.ToString("HH:mm") + "-" + myp.stop.ToString("HH:mm") + " " + myp.title, Width = 400, FontSize = 9, Tag = myp
                    };
                    myp.Parent = tb;
                    Border bo = inBorder(tb);
                    if (myp.stop < DateTime.Now)
                    {
                        bo.Style = sOld;
                    }
                    tb.MouseLeave += (x, z) =>
                    {
                        if (myp.stop < DateTime.Now)
                        {
                            bo.Style = sOld;
                        }
                        else
                        {
                            bo.Style = sOrg;
                        }
                    };
                    tb.MouseEnter += (x, z) =>
                    {
                        bo.Style          = sAlt;
                        canvas.Visibility = Visibility.Collapsed;
                        showCanvas(z.GetPosition(LayoutRoot));

                        info.Text = myp.start.ToString("yyyy-MM-dd HH:mm") + "-" + myp.stop.ToString("HH:mm") + "\r" +
                                    myp.title + (!string.IsNullOrEmpty(myp.subtitle) ? " - " + myp.subtitle : "") +
                                    "\r" + myp.desc;
                    };
                    sp.Children.Add(bo);

                    programmes.Children.Add(sp);
                }
            }
        }