示例#1
0
        protected override void OnApplyTemplate()
        {
            VIEW_BOX = GetTemplateChild(nameof(VIEW_BOX)) as Viewbox;
            PATH     = GetTemplateChild(nameof(PATH)) as Path;
            CHILDREN = GetTemplateChild(nameof(CHILDREN)) as Grid;

            PATH.SetBinding(Windows.UI.Xaml.Shapes.Path.DataProperty, new Binding()
            {
                Path   = new PropertyPath("Path"),
                Source = this
            });

            VIEW_BOX.SetBinding(Viewbox.StretchProperty, new Binding()
            {
                Path   = new PropertyPath("Stretch"),
                Source = this
            });

            PATH.Opacity = PathVisibility == Visibility.Visible ? 0.5 : 0;

            if (ExtendedGeometry != null)
            {
                PATH.Margin = new Thickness(-ExtendedGeometry.PathOffset.X, -ExtendedGeometry.PathOffset.Y, 0, 0);
            }

            foreach (var child in _children)
            {
                CHILDREN.Children.Add(new LayoutPathChildWrapper(child as FrameworkElement, ChildrenAlignment, ChildrenOrientation));
            }

            //TODO: _children.Clear does not invoke this event.
            _children.CollectionChanged += ChildrenOnCollectionChanged;

            base.OnApplyTemplate();
        }
示例#2
0
        public Viewbox GetMoreIcon()
        {
            var xc = (from c in PathIcon.Instance.xmlDoc.Descendants(Icon)
                      select c).FirstOrDefault();

            if (xc != null)
            {
                //拆分path
                string nv      = $"<ay>{xc.Value}</ay>";
                var    xd      = XDocument.Parse(nv);
                var    results = from c in xd.Descendants("path")
                                 select c;
                Viewbox vb           = new Viewbox();
                Binding bindingWidth = new Binding {
                    Path = new PropertyPath("Width"), Source = this, Mode = BindingMode.TwoWay, TargetNullValue = 16.00
                };
                vb.SetBinding(Viewbox.WidthProperty, bindingWidth);
                Binding bindingHeight = new Binding {
                    Path = new PropertyPath("Height"), Source = this, Mode = BindingMode.TwoWay, TargetNullValue = 16.00
                };
                vb.SetBinding(Viewbox.HeightProperty, bindingHeight);
                Grid g = new Grid();
                vb.Child = g;
                Brush defaultFil = null;

                var _hasbg = xc.Attribute("main");
                if (_hasbg != null && _hasbg.Value == "1")
                {
                    Foreground = null;
                }
                if (Foreground == null)
                {
                    var _hasFill = xc.Attribute("fil");
                    if (_hasFill != null && _hasFill.Value != "")
                    {
                        defaultFil = HexToBrush.FromHex(_hasFill.Value);
                    }

                    foreach (var result in results)
                    {
                        if (!string.IsNullOrEmpty(result.Attribute("d").Value))
                        {
                            Path p = new Path();
                            p.Data = PathGeometry.Parse(result.Attribute("d").Value);
                            if (defaultFil != null)
                            {
                                p.Fill = defaultFil;
                            }
                            else
                            {
                                var yanse = result.Attribute("fill");
                                if (yanse != null && yanse.Value != "")
                                {
                                    p.Fill = HexToBrush.FromHex(yanse.Value);
                                }
                                else
                                {
                                    var _hasEFill = xc.Attribute("efil");
                                    if (_hasEFill != null && _hasEFill.Value != "")
                                    {
                                        p.Fill = HexToBrush.FromHex(_hasEFill.Value);
                                    }
                                    else
                                    {
                                        if (EFil != null)
                                        {
                                            Binding bindingEfill = new Binding {
                                                Path = new PropertyPath("EFil"), Source = this, Mode = BindingMode.TwoWay
                                            };
                                            p.SetBinding(Path.FillProperty, bindingEfill);
                                        }
                                    }
                                }
                            }
                            g.Children.Add(p);
                        }
                    }
                }
                else
                {
                    foreach (var result in results)
                    {
                        if (!string.IsNullOrEmpty(result.Attribute("d").Value))
                        {
                            Path p = new Path();
                            p.Data = PathGeometry.Parse(result.Attribute("d").Value);
                            Binding bindingFill = new Binding {
                                Path = new PropertyPath("Foreground"), Source = this, Mode = BindingMode.TwoWay
                            };
                            p.SetBinding(Path.FillProperty, bindingFill);
                            Binding bindingStroke = new Binding {
                                Path = new PropertyPath("Stroke"), Source = this, Mode = BindingMode.TwoWay
                            };
                            p.SetBinding(Path.StrokeProperty, bindingStroke);

                            Binding bindingStrokeThickness = new Binding {
                                Path = new PropertyPath("StrokeThickness"), Source = this, Mode = BindingMode.TwoWay
                            };
                            p.SetBinding(Path.StrokeThicknessProperty, bindingStrokeThickness);

                            g.Children.Add(p);
                        }
                    }
                }
                Binding bindingStretch = new Binding {
                    Path = new PropertyPath("Stretch"), Source = this, Mode = BindingMode.TwoWay
                };
                vb.SetBinding(Viewbox.StretchProperty, bindingStretch);
                return(vb);
            }
            return(null);
        }
示例#3
0
        private void DisplayRacerConfig()
        {
            inRacerConfigScreen = true;

            //TODOb this only shows ant plus sources
            ListBox_RacerOrSources.Items.Clear();
            Button_AddRacer.Visibility     = System.Windows.Visibility.Hidden;
            ComboBox_RaceLength.Visibility = System.Windows.Visibility.Visible;
            Button_Start.Visibility        = System.Windows.Visibility.Hidden;
            Label_DisplayTitle.Content     = "Configure New Racer - Source and Track Length:";
            ComboBox_RaceLength.Items.Clear();

            AntPlusDevMgr antMgr    = AntConfigPanel.accessInstance().antMgr;
            Binding       widthBind = new Binding("ActualWidth");

            widthBind.Source = ListBox_RacerOrSources;

            bool select0 = false;

            dsOnDisplay = new List <DataSourceBase>();

            //Add current source
            if (racerIndexUnderConfig >= 0)
            {
                dsOnDisplay.Add(configuredRacers[racerIndexUnderConfig].dataSource);
                select0 = true;
            }

            for (int i = 0; i < antMgr.deviceList.Count; ++i)
            {
                AntPlusDevMgr.AntPlus_Connection dev = antMgr.deviceList[i];
                //Skip devices in use
                if (dev.dataSource.isInUse || dev.getConnStatus() != AntPlusDevMgr.AntPlus_Connection.ConnState.Connected || isDataSourceReserved(dev.dataSource))
                {
                    continue;
                }
                else
                {
                    dsOnDisplay.Add(dev.dataSource);
                }
            }

            if (dsOnDisplay.Count > 0)
            {
                foreach (DataSourceBase i in dsOnDisplay)
                {
                    //Show as option in list
                    Label name = new Label();
                    name.Content = i.getSportType() + "-" + i.getSourceName();
                    Viewbox vb = new Viewbox();
                    vb.SetBinding(Viewbox.WidthProperty, widthBind);
                    vb.Margin = new Thickness(0, 1, 20, 1);
                    vb.Child  = name;
                    ListBox_RacerOrSources.Items.Add(vb);

                    if (select0)
                    {
                        ListBox_RacerOrSources.SelectedIndex = 0;
                    }

                    Button_RacerAddOrFinish.IsEnabled    = true;
                    Button_RacerRemoveOrCancel.IsEnabled = true;
                }
            }
            else
            {
                Label_DisplayTitle.Content           = "...No Data Sources Available";
                Button_RacerAddOrFinish.IsEnabled    = false;
                Button_RacerRemoveOrCancel.IsEnabled = true;
            }

            Label lbl2 = new Label()
            {
                Content = "Save"
            };
            Viewbox vb2 = new Viewbox()
            {
                Child = lbl2
            };

            Button_RacerAddOrFinish.Content = vb2;
            Label lbl3 = new Label()
            {
                Content = "Cancel"
            };
            Viewbox vb3 = new Viewbox()
            {
                Child = lbl3
            };

            Button_RacerRemoveOrCancel.Content = vb3;
        }
示例#4
0
        private void DisplayRacerList()
        {
            inRacerConfigScreen = false;

            ListBox_RacerOrSources.Items.Clear();
            Button_AddRacer.Visibility     = System.Windows.Visibility.Visible;
            ComboBox_RaceLength.Visibility = System.Windows.Visibility.Hidden;
            Button_Start.Visibility        = System.Windows.Visibility.Visible;
            Label_DisplayTitle.Content     = "Racer List:";

            Binding widthBind = new Binding("ActualWidth");

            widthBind.Source = ListBox_RacerOrSources;

            if (configuredRacers.Count > 0)
            {
                for (int i = 0; i < configuredRacers.Count; ++i)
                {
                    Viewbox vb       = new Viewbox();
                    Label   racerLbl = new Label();
                    vb.SetBinding(Viewbox.WidthProperty, widthBind);
                    vb.Margin = new Thickness(0, 1, 30, 1);
                    vb.Child  = racerLbl;
                    if (configuredRacers[i].racerRecordInfo != null && !String.IsNullOrWhiteSpace(configuredRacers[i].racerRecordInfo.FirstName))
                    {
                        racerLbl.Content = String.Format("{0}: {1} {2}m-{3}", configuredRacers[i].racerRecordInfo.FirstName, configuredRacers[i].dataSource.getSportType(), configuredRacers[i].targetValue, configuredRacers[i].dataSource.getSourceName());
                    }
                    else if (configuredRacers[i].racerRecordInfo != null && !String.IsNullOrWhiteSpace(configuredRacers[i].racerRecordInfo.LastName))
                    {
                        racerLbl.Content = String.Format("{0}: {1} {2}m-{3}", configuredRacers[i].racerRecordInfo.LastName, configuredRacers[i].dataSource.getSportType(), configuredRacers[i].targetValue, configuredRacers[i].dataSource.getSourceName());
                    }
                    else
                    {
                        racerLbl.Content = String.Format("Racer {0}: {1} {2}m-{3}", i + 1, configuredRacers[i].dataSource.getSportType(), configuredRacers[i].targetValue, configuredRacers[i].dataSource.getSourceName());
                    }
                    ListBox_RacerOrSources.Items.Add(vb);
                }
                Button_Start.IsEnabled = true;
            }
            else
            {
                Label_DisplayTitle.Content = "Racer List:";
                Button_Start.IsEnabled     = false;
            }

            Label lbl2 = new Label()
            {
                Content = "Change Racer"
            };
            Viewbox vb2 = new Viewbox()
            {
                Child = lbl2
            };

            Button_RacerAddOrFinish.Content = vb2;
            Label lbl3 = new Label()
            {
                Content = "Remove Racer"
            };
            Viewbox vb3 = new Viewbox()
            {
                Child = lbl3
            };

            Button_RacerRemoveOrCancel.Content = vb3;

            Button_RacerAddOrFinish.IsEnabled    = false;
            Button_RacerRemoveOrCancel.IsEnabled = false;

            if (racerIndexUnderConfig >= 0)
            {
                ListBox_RacerOrSources.SelectedIndex = racerIndexUnderConfig;
            }
            else
            {
                ListBox_RacerOrSources.SelectedIndex = -1;
                Image_SelectionImage.Source          = RacerInfoPanel.getRaceDisplayBitmap(racerSportType.Unknown);
            }
        }