/// <summary>
        /// Default constructor builds a ComboBox inline editor template.
        /// </summary>
        public CultureInfoEditor()
        {
            // not using databinding here because Silverlight does not support
            // the WPF CultureConverter that is used by Blend.
            FrameworkElementFactory comboBox = new FrameworkElementFactory(typeof(ComboBox));
            comboBox.AddHandler(
                ComboBox.LoadedEvent,
                new RoutedEventHandler(
                    (sender, e) =>
                    {
                        _owner = (ComboBox)sender;
                        _owner.SelectionChanged += EditorSelectionChanged;
                        INotifyPropertyChanged data = _owner.DataContext as INotifyPropertyChanged;
                        if (data != null)
                        {
                            data.PropertyChanged += DatacontextPropertyChanged;
                        }
                        _owner.DataContextChanged += CultureDatacontextChanged;
                    }));

            comboBox.SetValue(ComboBox.IsEditableProperty, false);
            comboBox.SetValue(ComboBox.DisplayMemberPathProperty, "DisplayName");
            comboBox.SetValue(ComboBox.ItemsSourceProperty, CultureInfo.GetCultures(CultureTypes.SpecificCultures));
            DataTemplate dt = new DataTemplate();
            dt.VisualTree = comboBox;

            InlineEditorTemplate = dt;
        }
Exemplo n.º 2
0
 internal static DataTemplate CreateFallbackViewTemplate(string errorText) {
     var factory = new FrameworkElementFactory(typeof(FallbackView));
     factory.SetValue(FallbackView.TextProperty, errorText);
     var res = new DataTemplate() { VisualTree = factory };
     res.Seal();
     return res;
 }
Exemplo n.º 3
0
		public void RecursiveSettingInSystem ()
		{
			var tempObjects = new[] {
				new {Name = "Test1"},
				new {Name = "Test2"}
			};

			var template = new DataTemplate (typeof (BindableViewCell)) {
				Bindings = { {BindableViewCell.NameProperty, new Binding ("Name")} }
			};

			var cell1 = (Cell)template.CreateContent ();
			cell1.BindingContext = tempObjects[0];
			cell1.Parent = new ListView ();

			var cell2 = (Cell)template.CreateContent ();
			cell2.BindingContext = tempObjects[1];
			cell2.Parent = new ListView ();

			var viewCell1 = (BindableViewCell) cell1;
			var viewCell2 = (BindableViewCell) cell2;

			Assert.AreEqual ("Test1", viewCell1.Name);
			Assert.AreEqual ("Test2", viewCell2.Name);

			Assert.AreEqual ("Test1", viewCell1.NameLabel.Text);
			Assert.AreEqual ("Test2", viewCell2.NameLabel.Text);
		}
Exemplo n.º 4
0
			public MyDataTemplateSelector()
			{
				_1Template = new DataTemplate(() =>
				{
					return new TextCell { Text = Success1 };
				});

				_2Template = new DataTemplate(() =>
				{
					return new TextCell { Text = Success2 };
				});

				_3Template = new DataTemplate(() =>
				{
					return new TextCell { Text = Success3 };
				});

				_4Template = new DataTemplate(() =>
				{
					return new TextCell { Text = Success4 };
				});

				_5Template = new DataTemplate(() =>
				{
					return new TextCell { Text = Success5 };
				});

				_6Template = new DataTemplate(() =>
				{
					return new TextCell { Text = Success6 };
				});
			}
Exemplo n.º 5
0
		public void Create()
		{
			var template = new DataTemplate (typeof(SwitchCell));
			var content = template.CreateContent();

			Assert.That (content, Is.InstanceOf<SwitchCell>());
		}
Exemplo n.º 6
0
		// TODO Add gallerys for ViewCell, ListView and TableView
		public CellTypeList ()
		{
			var itemList = new List<CellNavigation> {
				new CellNavigation ("TextCell List", new TextCellListPage ()),
				new CellNavigation ("TextCell Table", new TextCellTablePage ()),
				new CellNavigation ("ImageCell List", new ImageCellListPage ()),
				new CellNavigation ("ImageCell Url List", new UrlImageCellListPage()),
				new CellNavigation ("ImageCell Table", new ImageCellTablePage ()),
				new CellNavigation ("SwitchCell List", new SwitchCellListPage ()),
				new CellNavigation ("SwitchCell Table", new SwitchCellTablePage ()),
				new CellNavigation ("EntryCell List", new EntryCellListPage ()),
				new CellNavigation ("EntryCell Table", new EntryCellTablePage ()),
				new CellNavigation ("ViewCell Image url table", new UrlImageViewCellListPage())
			};
			
			ItemsSource = itemList;

			var template = new DataTemplate (typeof (TextCell));
			template.SetBinding (TextCell.TextProperty, new Binding ("CellType"));

			ItemTemplate = template;
			ItemSelected += (s, e) => {
				if (SelectedItem == null)
					return;

				var cellNav = (CellNavigation) e.SelectedItem;
				Navigation.PushAsync (cellNav.Page);
				SelectedItem = null;
			};
		}		
            public ViewPresenter(DataTemplate viewTemplate, DataTemplateSelector viewTemplateSelector) {
                ContentTemplate = viewTemplate;
#if !SILVERLIGHT
                ContentTemplateSelector = viewTemplateSelector;
#endif
                Loaded += ViewPresenter_Loaded;
            }
Exemplo n.º 8
0
		public void CreateContentType()
		{
			var template = new DataTemplate (typeof (MockBindable));
			object obj = template.CreateContent();

			Assert.IsNotNull (obj);
			Assert.That (obj, Is.InstanceOf<MockBindable>());
		}
Exemplo n.º 9
0
		public void On()
		{
			var template = new DataTemplate (typeof (SwitchCell));
			template.SetValue (SwitchCell.OnProperty, true);

			SwitchCell cell = (SwitchCell)template.CreateContent();
			Assert.That (cell.On, Is.EqualTo (true));
		}
Exemplo n.º 10
0
		public void Text()
		{
			var template = new DataTemplate (typeof (SwitchCell));
			template.SetValue (SwitchCell.TextProperty, "text");			

			SwitchCell cell = (SwitchCell)template.CreateContent();
			Assert.That (cell.Text, Is.EqualTo ("text"));
		}
Exemplo n.º 11
0
 /// <summary>
 /// Default constructor builds the default TextBox inline editor template.
 /// </summary>
 public EmptyEditor()
 {
     FrameworkElementFactory textBox = new FrameworkElementFactory(typeof(TextBox));
     textBox.SetValue(TextBox.IsReadOnlyProperty, true);
     DataTemplate dt = new DataTemplate();
     dt.VisualTree = textBox;
     InlineEditorTemplate = dt;
 }
Exemplo n.º 12
0
		public void CreateContentValues()
		{
			var template = new DataTemplate (typeof (MockBindable)) {
				Values = { { MockBindable.TextProperty, "value" } }
			};

			MockBindable bindable = (MockBindable)template.CreateContent();
			Assert.That (bindable.GetValue (MockBindable.TextProperty), Is.EqualTo ("value"));
		}
Exemplo n.º 13
0
 public static object CreateView(IViewLocator viewLocator, string documentType, DataTemplate viewTemplate = null, DataTemplateSelector viewTemplateSelector = null) {
     if(documentType == null && viewTemplate == null & viewTemplateSelector == null)
         throw new InvalidOperationException(string.Format("{0}{1}To learn more, see: {2}", Error_CreateViewMissArguments, System.Environment.NewLine, HelpLink_CreateViewMissArguments));
     if(viewTemplate != null || viewTemplateSelector != null) {
         return new ViewPresenter(viewTemplate, viewTemplateSelector);
     }
     IViewLocator actualLocator = viewLocator ?? (ViewLocator.Default ?? ViewLocator.Instance);
     return actualLocator.ResolveView(documentType);
 }
Exemplo n.º 14
0
		public void CreateContentBindings()
		{
			var template = new DataTemplate (() => new MockBindable()) {
				Bindings = { { MockBindable.TextProperty, new Binding (".") } }
			};

			MockBindable bindable = (MockBindable)template.CreateContent();
			bindable.BindingContext = "text";
			Assert.That (bindable.GetValue (MockBindable.TextProperty), Is.EqualTo ("text"));
		}
Exemplo n.º 15
0
        public void PrepareContainerForItem(object item, DataTemplate template)
        {
            if (!ContainsValue(ContentTemplateProperty) && !ContainsValue(ContentTemplateSelectorProperty))
            {
                this.ContentTemplate = template;
                isContainerTemplate = true;
            }

            Content = item;
        }
Exemplo n.º 16
0
        public void DetailsTemplate()
        {
            Type propertyType = typeof(DataTemplate);
            bool expectGet = true;
            bool expectSet = true;
            bool hasSideEffects = true;

            DataGridRow control = new DataGridRow();
            Assert.IsNotNull(control);

            // Verify Dependency Property Property member
            FieldInfo fieldInfo = typeof(DataGridRow).GetField("DetailsTemplateProperty", BindingFlags.Static | BindingFlags.Public);
            Assert.AreEqual(typeof(DependencyProperty), fieldInfo.FieldType, "DataGridRow.DetailsTemplateProperty not expected type 'DependencyProperty'.");

            // Verify Dependency Property Property's value type
            DependencyProperty property = fieldInfo.GetValue(null) as DependencyProperty;

            Assert.IsNotNull(property);

            // 


            // Verify Dependency Property CLR property member
            PropertyInfo propertyInfo = typeof(DataGridRow).GetProperty("DetailsTemplate", BindingFlags.Instance | BindingFlags.Public);
            Assert.IsNotNull(propertyInfo, "Expected CLR property DataGridRow.DetailsTemplate does not exist.");
            Assert.AreEqual(propertyType, propertyInfo.PropertyType, "DataGridRow.DetailsTemplate not expected type 'DataTemplate'.");

            // Verify getter/setter access
            Assert.AreEqual(expectGet, propertyInfo.CanRead, "Unexpected value for propertyInfo.CanRead.");
            Assert.AreEqual(expectSet, propertyInfo.CanWrite, "Unexpected value for propertyInfo.CanWrite.");

            // Verify that we set what we get
            if (expectSet) // if expectSet == false, this block can be removed
            {
                DataTemplate template = new DataTemplate();

                control.DetailsTemplate = template;

                Assert.AreEqual(template, control.DetailsTemplate);
            }

            // Verify Dependency Property callback
            if (hasSideEffects)
            {
                MethodInfo methodInfo = typeof(DataGridRow).GetMethod("OnDetailsTemplatePropertyChanged", BindingFlags.Static | BindingFlags.NonPublic);
                Assert.IsNotNull(methodInfo, "Expected DataGridRow.DetailsTemplate to have static, non-public side-effect callback 'OnDetailsTemplatePropertyChanged'.");

                // 
            }
            else
            {
                MethodInfo methodInfo = typeof(DataGridRow).GetMethod("OnDetailsTemplatePropertyChanged", BindingFlags.Static | BindingFlags.NonPublic);
                Assert.IsNull(methodInfo, "Expected DataGridRow.DetailsTemplate NOT to have static side-effect callback 'OnDetailsTemplatePropertyChanged'.");
            }
        }
Exemplo n.º 17
0
 public static DataTemplate CreateViewTemplate(this IViewLocator viewLocator, Type viewType) {
     Verify(viewLocator);
     if(viewType == null) throw new ArgumentNullException("viewType");
     DataTemplate res = null;
     try {
         res = new DataTemplate() { VisualTree = new FrameworkElementFactory(viewType) };
         res.Seal();
     } catch {
         res = CreateFallbackViewTemplate(GetErrorMessage_CannotCreateDataTemplateFromViewType(viewType.Name));
     }
     return res;
 }
Exemplo n.º 18
0
		public void SetBindingOverridesValue()
		{
			var template = new DataTemplate (typeof (MockBindable));
			template.SetValue (MockBindable.TextProperty, "value");
			template.SetBinding (MockBindable.TextProperty, new Binding ("."));

			MockBindable bindable = (MockBindable) template.CreateContent();
			Assume.That (bindable.GetValue (MockBindable.TextProperty), Is.EqualTo (bindable.BindingContext));

			bindable.BindingContext = "binding";
			Assert.That (bindable.GetValue (MockBindable.TextProperty), Is.EqualTo ("binding"));
		}
Exemplo n.º 19
0
        /// <summary>
        /// Default constructor builds the default TextBox inline editor template.
        /// </summary>
        public TextBoxEditor()
        {
            FrameworkElementFactory textBox = new FrameworkElementFactory(typeof(TextBox));
            Binding binding = new Binding();
            binding.Path = new PropertyPath("Value");
            binding.Mode = BindingMode.TwoWay;
            textBox.SetBinding(TextBox.TextProperty, binding);

            DataTemplate dt = new DataTemplate();
            dt.VisualTree = textBox;

            InlineEditorTemplate = dt;
        }
Exemplo n.º 20
0
			public void EmptyTextCell (bool useCompiledXaml)
			{
				var layout = new DataTemplate (useCompiledXaml);

				var cell0 = layout.emptyTextCell.ItemTemplate.CreateContent ();
				Assert.NotNull (cell0);
				Assert.That (cell0, Is.TypeOf<TextCell> ());

				var cell1 = layout.emptyTextCell.ItemTemplate.CreateContent ();
				Assert.NotNull (cell1);
				Assert.That (cell1, Is.TypeOf<TextCell> ());

				Assert.AreNotSame (cell0, cell1);
			}
Exemplo n.º 21
0
		public ImageCellListPage ()
		{
			Title = "ImageCell List Gallery - Legacy";

			Device.OnPlatform (iOS: () => {
				if (Device.Idiom == TargetIdiom.Tablet) {
					Padding = new Thickness (0, 0, 0, 60);
				}
			});

			var dataTemplate = new DataTemplate (typeof (ImageCell));
			var stringToImageSourceConverter = new GenericValueConverter (
				obj => new FileImageSource {
					File = (string) obj
				}
				);
	
			dataTemplate.SetBinding (TextCell.TextProperty, new Binding ("Text"));
			dataTemplate.SetBinding (TextCell.TextColorProperty, new Binding ("TextColor"));
			dataTemplate.SetBinding (TextCell.DetailProperty, new Binding ("Detail"));
			dataTemplate.SetBinding (TextCell.DetailColorProperty, new Binding ("DetailColor"));
			dataTemplate.SetBinding (ImageCell.ImageSourceProperty, new Binding ("Image", converter: stringToImageSourceConverter));

			Random rand = new Random(250);

			var albums = new [] {
				"crimsonsmall.jpg",
				"oasissmall.jpg",
				"cover1small.jpg"
			};

			var label = new Label { Text = "I have not been selected" };

			var listView = new ListView {
				AutomationId = "ImageCellListView",
				ItemsSource = Enumerable.Range (0, 100).Select (i => new ImageCellTest {
					Text = "Text " + i,
					TextColor = i % 2 == 0 ? Color.Red : Color.Blue,
					Detail = "Detail " + i,
					DetailColor = i % 2 == 0 ? Color.Red : Color.Blue,
					Image = albums[rand.Next(0,3)]
				}),
				ItemTemplate = dataTemplate
			};

			listView.ItemSelected += (sender, args) => label.Text = "I was selected";

			Content = new StackLayout { Children = { label, listView } };

		}
Exemplo n.º 22
0
        public virtual void ClearContainerForItem(object item)
        {
            if (itemTemplate == ContentTemplate)
            {
                ClearValue(ContentTemplateProperty);
                itemTemplate = null;
            }

            if (itemContainerStyle == Style)
            {
                ClearValue(StyleProperty);
                itemContainerStyle = null;
            }

            ClearValue(ContentProperty);
        }
Exemplo n.º 23
0
		public UrlImageCellListPage()
		{
			Device.OnPlatform (iOS: () => {
				if (Device.Idiom == TargetIdiom.Tablet) {
					Padding = new Thickness (0, 0, 0, 60);
				}
			});

			var dataTemplate = new DataTemplate (typeof (ImageCell));
			var stringToImageSourceConverter = new GenericValueConverter (
				obj => new UriImageSource() {
					Uri = new Uri ((string) obj)
				});

			dataTemplate.SetBinding (TextCell.TextProperty, new Binding ("Text"));
			dataTemplate.SetBinding (TextCell.TextColorProperty, new Binding ("TextColor"));
			dataTemplate.SetBinding (TextCell.DetailProperty, new Binding ("Detail"));
			dataTemplate.SetBinding (TextCell.DetailColorProperty, new Binding ("DetailColor"));
			dataTemplate.SetBinding (ImageCell.ImageSourceProperty,
				new Binding ("Image", converter: stringToImageSourceConverter));

			var albums = new List<string> ();
			for (int i = 0; i < 30; i++) {
				albums.Add (string.Format ("http://cdn.instructables.com/FCP/9TOJ/GCJ0ZQV5/FCP9TOJGCJ0ZQV5.MEDIUM.jpg?ticks={0}",i ));
			}


			var random = new Random();
			var label = new Label { Text = "I have not been selected" };

			var listView = new ListView {
				AutomationId = "ImageUrlCellListView",
				ItemsSource = Enumerable.Range (0, 300).Select (i => new ImageCellTest {
					Text = "Text " + i,
					TextColor = i % 2 == 0 ? Color.Red : Color.Blue,
					Detail = "Detail " + i,
					DetailColor = i % 2 == 0 ? Color.Red : Color.Blue,
					Image = albums [random.Next (0, albums.Count - 1)]
				}),
				ItemTemplate = dataTemplate
			};

			listView.ItemSelected += (sender, args) => label.Text = "I was selected";

			Content = new StackLayout { Children = { label, listView } };

		}
Exemplo n.º 24
0
			public void TextCellAccessResources (bool useCompiledXaml)
			{
				var layout = new DataTemplate (useCompiledXaml);
				var cell0 = layout.textCellAccessResource.ItemTemplate.CreateContent ();
				Assert.NotNull (cell0);
				Assert.That (cell0, Is.TypeOf<TextCell> ());
				((TextCell)cell0).BindingContext = "Foo";
				Assert.AreEqual ("ooF", ((TextCell)cell0).Text);

				var cell1 = layout.textCellAccessResource.ItemTemplate.CreateContent ();
				Assert.NotNull (cell1);
				Assert.That (cell1, Is.TypeOf<TextCell> ());
				((TextCell)cell1).BindingContext = "Bar";
				Assert.AreEqual ("raB", ((TextCell)cell1).Text);

				Assert.AreNotSame (cell0, cell1);
			}
Exemplo n.º 25
0
		protected override void Init ()
		{
			Title = "List Page";

			var items = new [] {
				new CustomViewCell (),
			};
				
			var cellTemplate = new DataTemplate (typeof(CustomViewCell));

			var list = new ListView () {
				ItemTemplate = cellTemplate,
				ItemsSource = items
			};

			Content = list;
		}
Exemplo n.º 26
0
        public void comboBox_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && (sender as ComboBox).DroppedDown == false) {

                //setup Element
                DataTemplate dataTemplate = new DataTemplate();
                dataTemplate.idProperty = lastId;

                Output output = new Output();
                DataField dataField = new DataField();

                dataTemplate.addTemplateElement(output);
                dataTemplate.addTemplateElement(dataField);

                lastId++;

                //Setup control
                Panel elementContainer = new Panel();
                Label elementTitle = new Label();
                Label elementValues = new Label();

                if ((sender as ComboBox).SelectedItem != null)
                {
                    string value = (sender as ComboBox).Text;
                    int split = value.IndexOf(':') + 2;
                    elementTitle.Text = value.Substring(split, value.Length - split);
                }

                Label label = new Label();
                if ((sender as ComboBox).SelectedItem != null) {
                    string value = (sender as ComboBox).SelectedItem.ToString();
                    int split = value.IndexOf(':') + 2;
                    label.Text = value.Substring(split, value.Length - split);
                }
                else {
                    string value = (sender as ComboBox).Text;
                    int split = value.IndexOf(':') + 2;
                    label.Text = value.Substring(split, value.Length - split);
                }
                label.AutoSize = true;
                makeControlMove(label);
                setActiveControl(label);
                (sender as ComboBox).DoDragDrop(label, DragDropEffects.All);
            }
        }
Exemplo n.º 27
0
		protected override void Init ()
		{
			var cells = new [] {
				new NavPageNameObject ("Close Master"),
				new NavPageNameObject ("Page 1"),
				new NavPageNameObject ("Page 3"),
				new NavPageNameObject ("Page 4"),
				new NavPageNameObject ("Page 5"),
				new NavPageNameObject ("Page 6"),
				new NavPageNameObject ("Page 7"),
				new NavPageNameObject ("Page 8"),
			};

			var template = new DataTemplate (typeof (TextCell));
			template.SetBinding (TextCell.TextProperty, "PageName");

			var listView = new ListView { 
				ItemTemplate = template,
				ItemsSource = cells
			};

			listView.BindingContext = cells;

			listView.ItemTapped += (sender, e) => {
				var cellName = ((NavPageNameObject)e.Item).PageName;
				if (cellName == "Close Master") {
					IsPresented = false;
				} else {
					Detail = new CustomNavDetailPage (cellName);
				}
			};

			var master = new ContentPage {
				Padding = new Thickness(0, 20, 0, 0),
				Title = "Master",
				Content = listView
			};
				
			Master = master;
			Detail = new CustomNavDetailPage ("Initial Page");

			MessagingCenter.Subscribe<NestedNavPageRootView> (this, "PresentMaster", (sender) => {
				IsPresented = true;
			});
		}
Exemplo n.º 28
0
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        static ContentPresenter()
        {
            DataTemplate template;
            FrameworkElementFactory text;
            Binding binding;

            // Default template for strings when hosted in ContentPresener with RecognizesAccessKey=true
            template = new DataTemplate();
            text = CreateAccessTextFactory();
            text.SetValue(AccessText.TextProperty, new TemplateBindingExtension(ContentProperty));
            template.VisualTree = text;
            template.Seal();
            s_AccessTextTemplate = template;

            // Default template for strings
            template = new DataTemplate();
            text = CreateTextBlockFactory();
            text.SetValue(TextBlock.TextProperty, new TemplateBindingExtension(ContentProperty));
            template.VisualTree = text;
            template.Seal();
            s_StringTemplate = template;

            // Default template for XmlNodes
            template = new DataTemplate();
            text = CreateTextBlockFactory();
            binding = new Binding();
            binding.XPath = ".";
            text.SetBinding(TextBlock.TextProperty, binding);
            template.VisualTree = text;
            template.Seal();
            s_XmlNodeTemplate = template;

            // Default template for UIElements
            template = new UseContentTemplate();
            template.Seal();
            s_UIElementTemplate = template;

            // Default template for everything else
            template = new DefaultTemplate();
            template.Seal();
            s_DefaultTemplate = template;

            // Default template selector
            s_DefaultTemplateSelector = new DefaultSelector();
        }
Exemplo n.º 29
0
			public ListViewTest ()
			{
				Title = "List Page";

				var items = new[] {
					new TabbedPageWithListName () { Name = "Jason" },
					new TabbedPageWithListName () { Name = "Ermau" },
					new TabbedPageWithListName () { Name = "Seth" }
				};

				var cellTemplate = new DataTemplate (typeof(TextCell));
				cellTemplate.SetBinding (TextCell.TextProperty, "Name");

				Content = new ListView () {
					ItemTemplate = cellTemplate,
					ItemsSource = items
				};
			}
Exemplo n.º 30
0
        public virtual void PrepareContainerForItem(object item, DataTemplate itemTemplate, Style itemContainerStyle)
        {
            if (!ContainsValue(ContentTemplateProperty) && !ContainsValue(ContentTemplateSelectorProperty) && itemTemplate != null)
            {
                ContentTemplate = itemTemplate;
                this.itemTemplate = itemTemplate;
            }

            if (!ContainsValue(StyleProperty) && itemContainerStyle != null)
            {
                Style = itemContainerStyle;
                this.itemContainerStyle = itemContainerStyle;
            }

            if (item != this)
            {
                Content = item;
            }
        }
Exemplo n.º 31
0
    public override void InitUIData()
    {
        base.InitUIData();
        MsgBoxGroup = selfTransform.FindChild("MsgBoxGroup");
        selfTransform.FindChild("ContinueButton").GetComponent <Button>().onClick.AddListener(new UnityEngine.Events.UnityAction(OnClickAddFightNum));
        selfTransform.FindChild("ReturnButton").GetComponent <Button>().onClick.AddListener(new UnityEngine.Events.UnityAction(OnCloseFightBuy));
        powerBuyNum = selfTransform.FindChild("BuyNum").GetComponent <Text>();
        needGold    = selfTransform.FindChild("NeedGold/Text").GetComponent <Text>();
        allGold     = selfTransform.FindChild("AllGold/Text").GetComponent <Text>();
        info        = ObjectSelf.GetInstance();

        //if (info.GetIsPrompt())
        //{
        //    list = info.BattleStageData.m_BattleStageList[1001];
        //}
        //else
        //{
        //    if (info.BattleStageData.m_BattleStageList.ContainsKey(info.GetCurChapterID()))
        //    {
        //        list = info.BattleStageData.m_BattleStageList[info.GetCurChapterID()];
        //    }

        //}

        BattleStage bs = StageModule.GetPlayerBattleStageInfo();

        if (bs != null)
        {
            list = bs;
        }

        data = list == null ? null : list.GetStageData(info.CurStageID);
        //VipTemplate vip = (VipTemplate)DataTemplate.GetInstance().m_VipTable.getTableData(info.VipLevel);
        //StageTemplate stageinfo = (StageTemplate)DataTemplate.GetInstance().m_StageTable.getTableData(info.CurStageID);
        VipTemplate   vip       = DataTemplate.GetInstance().GetVipTemplateById(info.VipLevel);
        StageTemplate stageinfo = StageModule.GetStageTemplateById(info.CurStageID);

        int[] needGoldList = stageinfo.m_resetCost;
        if (needGoldList.Length > 0)
        {
            if (vip.getStageResetBuyTimes() > 0)
            {
                if (data.m_BuyBattleNum == vip.getStageResetBuyTimes())
                {
                    needGoldNum = needGoldList[needGoldList.Length - 1];
                }
                else
                {
                    if (needGoldList.Length < data.m_BuyBattleNum)
                    {
                        needGoldNum = needGoldList[needGoldList.Length - 1];
                    }
                    else
                    {
                        needGoldNum = needGoldList[data.m_BuyBattleNum];
                    }
                }
            }
            else
            {
                needGoldNum = needGoldList[0];
            }
        }
        powerBuyNum.text = (vip.getStageResetBuyTimes() - data.m_BuyBattleNum).ToString();
        needGold.text    = needGoldNum.ToString();
        allGold.text     = info.Gold.ToString();
    }
Exemplo n.º 32
0
        private void Picker_OnTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            FrameworkElement frameworkElement1 = this.ParentElement ?? (FrameworkElement)this.Page;
            Point            point1            = base.TransformToVisual((UIElement)frameworkElement1).Transform(new Point(0.0, 0.0));
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            double num1 = point1.X - 16.0;

            point1.X = num1;
            // ISSUE: explicit reference operation
            if (point1.X + this.PickerWidth > 474.0)
            {
                // ISSUE: explicit reference operation
                point1.X = (474.0 - this.PickerWidth);
            }
            Grid grid1 = new Grid();
            int  num2  = 0;

            ((FrameworkElement)grid1).VerticalAlignment = ((VerticalAlignment)num2);
            int num3 = 0;

            ((FrameworkElement)grid1).HorizontalAlignment = ((HorizontalAlignment)num3);
            Grid grid2 = grid1;
            ObservableCollection <ListPickerListItem> observableCollection = new ObservableCollection <ListPickerListItem>();
            ListPickerListItem listPickerListItem1 = null;

            foreach (object fromObj in (IEnumerable)this.ItemsSource)
            {
                ListPickerListItem listPickerListItem2 = new ListPickerListItem(fromObj)
                {
                    Prefix = this.ItemPrefix
                };
                observableCollection.Add(listPickerListItem2);
                object selectedItem = this.SelectedItem;
                if (fromObj == selectedItem)
                {
                    listPickerListItem2.IsSelected = true;
                    listPickerListItem1            = listPickerListItem2;
                }
            }
            ListPickerItemsUC listPickerItemsUc = new ListPickerItemsUC();

            listPickerItemsUc.ItemsSource  = observableCollection;
            listPickerItemsUc.SelectedItem = listPickerListItem1;
            DataTemplate itemTemplate = this.ItemTemplate;

            listPickerItemsUc.ItemTemplate = itemTemplate;
            double pickerMaxHeight = this.PickerMaxHeight;

            listPickerItemsUc.PickerMaxHeight = pickerMaxHeight;
            double pickerWidth = this.PickerWidth;

            listPickerItemsUc.PickerWidth = pickerWidth;
            FrameworkElement frameworkElement2 = frameworkElement1;

            listPickerItemsUc.ParentElement = frameworkElement2;
            Point point2 = point1;

            listPickerItemsUc.ShowPosition = point2;
            ListPickerItemsUC picker = listPickerItemsUc;

            ((PresentationFrameworkCollection <UIElement>)((Panel)grid2).Children).Add((UIElement)picker);
            DialogService dialogService = new DialogService();

            dialogService.AnimationType = DialogService.AnimationTypes.None;
            SolidColorBrush solidColorBrush = new SolidColorBrush(Colors.Transparent);

            dialogService.BackgroundBrush = (Brush)solidColorBrush;
            Grid grid3 = grid2;

            dialogService.Child = (FrameworkElement)grid3;
            DialogService ds = dialogService;

            ((UIElement)picker.listBox).Tap += ((EventHandler <System.Windows.Input.GestureEventArgs>)((o, args) =>
            {
                ListPickerListItem selectedItem = picker.listBox.SelectedItem as ListPickerListItem;
                if (selectedItem != null)
                {
                    this.SelectedItem = this.ItemsSource[picker.ItemsSource.IndexOf(selectedItem)];
                }
                ((Timeline)picker.AnimClipHide).Completed += ((EventHandler)((sender1, eventArgs) => ds.Hide()));
                picker.AnimClipHide.Begin();
            }));
            picker.Setup();
            ds.Opened += (EventHandler)((o, args) => picker.AnimClip.Begin());
            ds.Show(null);
        }
Exemplo n.º 33
0
 public RecipeDetailStepTemplateSelector()
 {
     _textTemplate  = new DataTemplate(typeof(TextStepView));
     _imageTemplate = new DataTemplate(typeof(ImageStepView));
 }
 private void SetDefaultDistinctValueItemContentTemplate(DataTemplate value)
 {
     this.SetValue(ForeignKeyConfiguration.DefaultDistinctValueItemContentTemplatePropertyKey, value);
 }
 private void SetDefaultScrollTipContentTemplate(DataTemplate value)
 {
     this.SetValue(ForeignKeyConfiguration.DefaultScrollTipContentTemplatePropertyKey, value);
 }
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            DataTemplate template = null;

            var element = container as FrameworkElement;

            if (element == null)
            {
                throw new Exception("Container must be of type FrameworkElement");
            }

            if (item is ViewModelReference && ((ViewModelReference)item).ViewModel.PropertyName == "EntityComponent")
            {
                if (componentTemplate == null)
                {
                    componentTemplate = (DataTemplate)element.FindResource("EntityComponentView");
                }
                template = componentTemplate;
            }
            else if (item is ViewModelReference)
            {
                return((DataTemplate)element.FindResource("ViewModelReference"));
            }
            else if (item is IViewModelNode)
            {
                var viewModel = (IViewModelNode)item;

                if (viewModel.Children.Count > 0)
                {
                    if (viewModelTemplate == null)
                    {
                        viewModelTemplate = (DataTemplate)element.FindResource("IViewModelNode");
                    }
                    template = viewModelTemplate;
                }
                else if (viewModel.Type == typeof(ViewModelReference))
                {
                    if (viewModel.PropertyName == "ObjectRef")
                    {
                        template = (DataTemplate)element.FindResource("ViewModelReferenceNode");
                    }
                    else
                    {
                        template = (DataTemplate)element.FindResource("ViewModelReferenceGuid");
                    }
                }
                else if (viewModel.Type == typeof(IList <ViewModelReference>))
                {
                    template = (DataTemplate)element.FindResource("ListViewModelReference");
                }
                else
                {
                    if (textTemplate == null)
                    {
                        textTemplate = (DataTemplate)element.FindResource("TextBox");
                    }
                    template = textTemplate;
                }
            }

            if (template == null)
            {
                if (errorTemplate == null)
                {
                    errorTemplate = (DataTemplate)element.FindResource("Error");
                }
                template = errorTemplate;
            }

            return(template);
        }
 public StoreItemDataTemplate()
 {
     _sell   = new DataTemplate(typeof(StoreItemSellContentView));
     _ads    = new DataTemplate(typeof(StoreItemAdsContentView));
     _normal = new DataTemplate(typeof(StoreItemNormalContentView));
 }
Exemplo n.º 38
0
 public static void SetButtonContentTemplate(DependencyObject obj, DataTemplate value)
 {
     obj.SetValue(ButtonContentTemplateProperty, value);
 }
Exemplo n.º 39
0
        public void Visit(ElementNode node, INode parentNode)
        {
            object value = null;

            var type = XamlParser.GetElementType(node.XmlType, node, Context.RootElement?.GetType().GetTypeInfo().Assembly,
                                                 out XamlParseException xpe);

            if (xpe != null)
            {
                if (Context.ExceptionHandler != null)
                {
                    Context.ExceptionHandler(xpe);
                    return;
                }
                throw xpe;
            }
            Context.Types[node] = type;
            if (IsXaml2009LanguagePrimitive(node))
            {
                value = CreateLanguagePrimitive(type, node);
            }
            else if (node.Properties.ContainsKey(XmlName.xArguments) || node.Properties.ContainsKey(XmlName.xFactoryMethod))
            {
                value = CreateFromFactory(type, node);
            }
            else if (
                type.GetTypeInfo()
                .DeclaredConstructors.Any(
                    ci =>
                    ci.IsPublic && ci.GetParameters().Length != 0 &&
                    ci.GetParameters().All(pi => pi.CustomAttributes.Any(attr => attr.AttributeType == typeof(ParameterAttribute)))) &&
                ValidateCtorArguments(type, node, out string ctorargname))
            {
                value = CreateFromParameterizedConstructor(type, node);
            }
            else if (!type.GetTypeInfo().DeclaredConstructors.Any(ci => ci.IsPublic && ci.GetParameters().Length == 0) &&
                     !ValidateCtorArguments(type, node, out ctorargname))
            {
                throw new XamlParseException($"The Property {ctorargname} is required to create a {type.FullName} object.", node);
            }
            else
            {
                //this is a trick as the DataTemplate parameterless ctor is internal, and we can't CreateInstance(..., false) on WP7
                try
                {
                    if (type == typeof(DataTemplate))
                    {
                        value = new DataTemplate();
                    }
                    if (type == typeof(ControlTemplate))
                    {
                        value = new ControlTemplate();
                    }
                    if (value == null && node.CollectionItems.Any() && node.CollectionItems.First() is ValueNode)
                    {
                        var serviceProvider = new XamlServiceProvider(node, Context);
                        var converted       = ((ValueNode)node.CollectionItems.First()).Value.ConvertTo(type, () => type.GetTypeInfo(),
                                                                                                        serviceProvider, out Exception exception);
                        if (exception != null)
                        {
                            if (Context.ExceptionHandler != null)
                            {
                                Context.ExceptionHandler(exception);
                                return;
                            }
                            throw exception;
                        }
                        if (converted != null && converted.GetType() == type)
                        {
                            value = converted;
                        }
                    }
                    if (value == null)
                    {
                        value = Activator.CreateInstance(type);
                    }
                }
                catch (TargetInvocationException e) when(e.InnerException is XamlParseException || e.InnerException is XmlException)
                {
                    throw e.InnerException;
                }
                catch (MissingMemberException mme)
                {
                    throw new XamlParseException(mme.Message, node, mme);
                }
            }

            Values[node] = value;

            if (value is IMarkupExtension markup && (value is TypeExtension || value is StaticExtension || value is ArrayExtension))
            {
                var serviceProvider = new XamlServiceProvider(node, Context);

                var visitor = new ApplyPropertiesVisitor(Context);
                foreach (var cnode in node.Properties.Values.ToList())
                {
                    cnode.Accept(visitor, node);
                }
                foreach (var cnode in node.CollectionItems)
                {
                    cnode.Accept(visitor, node);
                }

                try
                {
                    value = markup.ProvideValue(serviceProvider);
                }
                catch (Exception e)
                {
                    var xamlpe = e as XamlParseException ?? new XamlParseException("Markup extension failed", serviceProvider, e);
                    if (Context.ExceptionHandler != null)
                    {
                        Context.ExceptionHandler(xamlpe);
                    }
                    else
                    {
                        throw xamlpe;
                    }
                }
                if (!node.Properties.TryGetValue(XmlName.xKey, out INode xKey))
                {
                    xKey = null;
                }

                node.Properties.Clear();
                node.CollectionItems.Clear();

                if (xKey != null)
                {
                    node.Properties.Add(XmlName.xKey, xKey);
                }

                Values[node] = value;
            }

            if (value is BindableObject bindableValue && node.NameScopeRef != (parentNode as IElementNode)?.NameScopeRef)
            {
                NameScope.SetNameScope(bindableValue, node.NameScopeRef.NameScope);
            }

            var assemblyName = (Context.RootAssembly ?? Context.RootElement?.GetType().GetTypeInfo().Assembly)?.GetName().Name;

            if (assemblyName != null && value != null && !value.GetType().GetTypeInfo().IsValueType&& XamlFilePathAttribute.GetFilePathForObject(Context.RootElement) is string path)
            {
                VisualDiagnostics.RegisterSourceInfo(value, new Uri($"{path};assembly={assemblyName}", UriKind.Relative), ((IXmlLineInfo)node).LineNumber, ((IXmlLineInfo)node).LinePosition);
            }
        }
 /// <summary>
 /// Occurs when the <see cref="ItemTemplate"/> property has changed.
 /// </summary>
 /// <param name="oldTemplate"></param>
 protected virtual void OnItemTemplateChanged(DataTemplate oldTemplate)
 {
 }
Exemplo n.º 41
0
 public static void SetHeaderTemplate(Page item, DataTemplate value)
 {
     item.SetValue(HeaderTemplateProperty, value);
 }
Exemplo n.º 42
0
 public AccordionView(DataTemplate itemTemplate)
 {
     this.SubTemplate = itemTemplate;
     this.Template    = new DataTemplate(() => (object)(new AccordionSectionView(itemTemplate, this)));
     this.Content     = _layout;
 }
Exemplo n.º 43
0
 public ChatDataTemplateSelector()
 {
     _incomingMessageTemplate   = new DataTemplate(typeof(IncomingViewCell));
     _outcommingMessageTemplate = new DataTemplate(typeof(OutcomingViewCell));
 }
Exemplo n.º 44
0
 protected ItemTemplateAdaptor(ItemsView itemsView, IEnumerable items, DataTemplate template) : base(items)
 {
     ItemTemplate = template;
     _itemsView   = itemsView;
     IsSelectable = itemsView is SelectableItemsView;
 }
 private void SetDefaultGroupValueTemplate(DataTemplate value)
 {
     this.SetValue(ForeignKeyConfiguration.DefaultGroupValueTemplatePropertyKey, value);
 }
Exemplo n.º 46
0
 private static bool ApplyTemplate(ContentControl container, DataTemplate dt, DataTemplateSelector dts)
 {
     container.ContentTemplate         = dt;
     container.ContentTemplateSelector = dts;
     return(container.ApplyTemplate());
 }
Exemplo n.º 47
0
 public QuoteCellDataTemplateSelector()
 {
     internalTemplate = new DataTemplate(typeof(InternalQuoteViewCell));
     externalTemplate = new DataTemplate(typeof(ExternalQuoteViewCell));
 }
Exemplo n.º 48
0
 public CardTemplateSelector()
 {
     this.dashboardcard = new DataTemplate(typeof(StateDashBoardCard));
     this.listcard      = new DataTemplate(typeof(StateCardView));
 }
Exemplo n.º 49
0
 /// <summary>
 /// Preserve the constructor prototype from PropertyValueEditor.
 /// </summary>
 /// <param name="inlineEditorTemplate">Inline editor template.</param>
 public EmptyEditor(DataTemplate inlineEditorTemplate)
     : base(inlineEditorTemplate)
 {
 }
Exemplo n.º 50
0
        public Master()
        {
            //*
            // Create ListView for the master page.
            var listView = new ListView();

            listView.Margin          = Device.OnPlatform(new Thickness(0, 10, 0, 0), new Thickness(0), new Thickness(0));
            listView.RowHeight       = 50;
            listView.BackgroundColor = Color.FromHex("dfdfdf");

            listView.SeparatorColor = Color.White;

            var template = new DataTemplate(typeof(TextCell));

            template.SetValue(TextCell.TextColorProperty, Color.White);


            listView.ItemsSource = new string[] {
                "Favoritos",
                "Los más buscados",
                "Los más vendidos",
                "Promoción del mes",
                "Conócenos",
                "Se nuestro proveedor",
                "Búscanos en Facebook"
            };
            //listView.ItemTemplate = template;



            this.Master = new ContentPage
            {
                Title = "menu",
                Icon  = "menuIcon.png",

                Content = new StackLayout
                {
                    Children =
                    {
                        new Image {
                            Source = "fotoDemo.jpg",
                            Margin = new Thickness(0, 30, 0, 0)
                        },
                        listView
                    }
                }
            };

            listView.ItemSelected += (sender, args) =>
            {
                DisplayAlert("Próximamente", args.SelectedItem.ToString(), "ok");
                // Set the BindingContext of the detail page.
                this.Detail.BindingContext = args.SelectedItem;

                // Show the detail page.
                this.IsPresented = false;

                //((ListView)sender).SelectedItem = null;
            };
            // */



            this.Detail = new NavigationPage(new tiendaMKTPage());


            //fin del constructor
        }
Exemplo n.º 51
0
 public static void SetColumnTemplate(DataGrid element, DataTemplate value)
 {
     element.SetValue(ColumnTemplateProperty, value);
 }
Exemplo n.º 52
0
        protected override void Init()
        {
            var cells = new[] {
                new PageNameObject("Close Flyout"),
                new PageNameObject("Page 1"),
                new PageNameObject("Page 2"),
                new PageNameObject("Page 3"),
                new PageNameObject("Page 4"),
                new PageNameObject("Page 5"),
                new PageNameObject("Page 6"),
                new PageNameObject("Page 7"),
                new PageNameObject("Page 8"),
            };

            var template = new DataTemplate(typeof(TextCell));

            template.SetBinding(TextCell.TextProperty, "PageName");

            var listView = new ListView
            {
                ItemTemplate = template,
                ItemsSource  = cells
            };

            listView.BindingContext = cells;

            listView.ItemTapped += (sender, e) =>
            {
                var cellName = ((PageNameObject)e.Item).PageName;

                if (cellName == "Close Flyout")
                {
                    IsPresented = false;
                }
                else
                {
                    var d = new CustomDetailPage(cellName)
                    {
                        Title = "Detail"
                    };

                    d.PresentMaster += (s, args) =>
                    {
                        IsPresented = true;
                    };

                    Detail = d;
                }
            };

            var master = new ContentPage
            {
                Padding = new Thickness(0, 20, 0, 0),
                Title   = "Flyout",
                Content = listView
            };

            Flyout = master;

            var detail = new CustomDetailPage("Initial Page")
            {
                Title = "Detail"
            };

            detail.PresentMaster += (sender, e) =>
            {
                IsPresented = true;
            };

            Detail = detail;
        }
Exemplo n.º 53
0
 protected override void OnContentTemplateChanged(DataTemplate oldContentTemplate, DataTemplate newContentTemplate)
 {
     base.OnContentTemplateChanged(oldContentTemplate, newContentTemplate);
 }
Exemplo n.º 54
0
 public static void SetDragAdornerTemplate(UIElement target, DataTemplate value)
 {
     target.SetValue(DragAdornerTemplateProperty, value);
 }
Exemplo n.º 55
0
        private void OnChartTypeSelectionChanged1(object sender, SelectionChangedEventArgs e)
        {
            ComboBox comboBox = sender as ComboBox;

            Accumulation_charts.Legend = null;

            if (comboBox.SelectedIndex == 0 && viewModel != null)
            {
                if (Accumulation_charts != null)
                {
                    if (Accumulation_charts.Legend == null)
                    {
                        Accumulation_charts.Legend = new ChartLegend()
                        {
                            CornerRadius    = new CornerRadius(0),
                            FontSize        = 15,
                            DockPosition    = ChartDock.Right,
                            BorderThickness = new Thickness(1)
                        };
                    }

                    PieSeries          series1        = new PieSeries();
                    ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo();

                    ChartLegend1.Visibility = Visibility.Visible;

                    DataTemplate template1 = MainGrid.Resources["labelTemplate"] as DataTemplate;
                    adornmentInfo1.ShowLabel           = true;
                    adornmentInfo1.LabelTemplate       = template1;
                    adornmentInfo1.AdornmentsPosition  = AdornmentsPosition.Bottom;
                    adornmentInfo1.HorizontalAlignment = HorizontalAlignment.Center;
                    adornmentInfo1.VerticalAlignment   = VerticalAlignment.Center;
                    adornmentInfo1.ShowConnectorLine   = true;
                    adornmentInfo1.ConnectorHeight     = 80;
                    adornmentInfo1.ShowLabel           = true;
                    adornmentInfo1.UseSeriesPalette    = true;
                    adornmentInfo1.SegmentLabelContent = LabelContent.LabelContentPath;

                    series1.XBindingPath      = "Countries";
                    series1.YBindingPath      = "Count";
                    series1.ItemsSource       = viewModel.CountryDetails;
                    series1.PieCoefficient    = 0.7;
                    series1.EnableSmartLabels = true;
                    series1.LabelPosition     = CircularSeriesLabelPosition.OutsideExtended;
                    series1.AdornmentsInfo    = adornmentInfo1;
                    series1.GroupMode         = PieGroupMode.Value;
                    series1.GroupTo           = 1000;

                    Accumulation_charts.Header = "Agriculture Expenses Comparison";
                    Accumulation_charts.Series.Clear();
                    Accumulation_charts.Series.Add(series1);
                }
            }
            if (comboBox.SelectedIndex == 1 && viewModel != null)
            {
                PieSeries series1 = new PieSeries();
                PieSeries series2 = new PieSeries();
                PieSeries series3 = new PieSeries();

                ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo();
                ChartAdornmentInfo adornmentInfo2 = new ChartAdornmentInfo();
                ChartAdornmentInfo adornmentInfo3 = new ChartAdornmentInfo();

                ChartColorModel color1 = new ChartColorModel();
                ChartColorModel color2 = new ChartColorModel();
                ChartColorModel color3 = new ChartColorModel();

                color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73)));
                color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84)));
                color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119)));

                color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73)));
                color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73)));
                color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84)));
                color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84)));
                color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119)));
                color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119)));

                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119)));

                DataTemplate template1 = MainGrid.Resources["populationLabelTemplate1"] as DataTemplate;
                DataTemplate template2 = MainGrid.Resources["populationLabelTemplate2"] as DataTemplate;
                DataTemplate template3 = MainGrid.Resources["populationLabelTemplate3"] as DataTemplate;

                ChartLegend1.Visibility = Visibility.Collapsed;

                adornmentInfo1.ShowLabel           = true;
                adornmentInfo1.SegmentLabelContent = LabelContent.LabelContentPath;
                adornmentInfo1.LabelTemplate       = template1;

                adornmentInfo2.ShowLabel           = true;
                adornmentInfo2.SegmentLabelContent = LabelContent.LabelContentPath;
                adornmentInfo2.LabelTemplate       = template2;

                adornmentInfo3.ShowLabel           = true;
                adornmentInfo3.SegmentLabelContent = LabelContent.LabelContentPath;
                adornmentInfo3.LabelTemplate       = template3;

                series1.ItemsSource    = viewModel.Population;
                series1.XBindingPath   = "Continent";
                series1.YBindingPath   = "PopulationinContinents";
                series1.AdornmentsInfo = adornmentInfo1;
                series1.Stroke         = new SolidColorBrush(Colors.White);
                series1.PieCoefficient = 1;
                series1.Label          = "Continents";
                series1.Palette        = ChartColorPalette.Custom;
                series1.ColorModel     = color1;

                series2.ItemsSource    = viewModel.Population;
                series2.XBindingPath   = "Countries";
                series2.YBindingPath   = "PopulationinCountries";
                series2.AdornmentsInfo = adornmentInfo2;
                series2.Stroke         = new SolidColorBrush(Colors.White);
                series2.PieCoefficient = 1;
                series2.Label          = "Countries";
                series2.Palette        = ChartColorPalette.Custom;
                series2.ColorModel     = color2;

                series3.ItemsSource    = viewModel.Population;
                series3.XBindingPath   = "States";
                series3.YBindingPath   = "PopulationinStates";
                series3.AdornmentsInfo = adornmentInfo3;
                series3.Stroke         = new SolidColorBrush(Colors.White);
                series3.PieCoefficient = 1;
                series3.Label          = "States";
                series3.Palette        = ChartColorPalette.Custom;
                series3.ColorModel     = color3;

                Accumulation_charts.Header = "Most populated continents";
                Accumulation_charts.Series.Clear();
                Accumulation_charts.Series.Add(series1);
                Accumulation_charts.Series.Add(series2);
                Accumulation_charts.Series.Add(series3);
            }
            if (comboBox.SelectedIndex == 2 && viewModel != null)
            {
                PieSeries          series1        = new PieSeries();
                ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo();

                ChartLegend1.Visibility = Visibility.Collapsed;

                series1.Margin                     = new Thickness(0, 25, 0, 0);
                adornmentInfo1.ShowLabel           = true;
                adornmentInfo1.ShowConnectorLine   = true;
                adornmentInfo1.UseSeriesPalette    = true;
                adornmentInfo1.ConnectorHeight     = 37;
                adornmentInfo1.SegmentLabelContent = LabelContent.Percentage;
                adornmentInfo1.SegmentLabelFormat  = "##.#";

                series1.XBindingPath      = "Utilization";
                series1.YBindingPath      = "ResponseTime";
                series1.StartAngle        = 180;
                series1.EndAngle          = 360;
                series1.EnableSmartLabels = true;
                series1.LabelPosition     = CircularSeriesLabelPosition.Outside;
                series1.ItemsSource       = viewModel.Metric;
                series1.AdornmentsInfo    = adornmentInfo1;

                Accumulation_charts.Header = "Application Performance Metrics";
                Accumulation_charts.Series.Clear();
                Accumulation_charts.Series.Add(series1);
            }
            if (comboBox.SelectedIndex == 3 && viewModel != null)
            {
                if (Accumulation_charts.Legend == null)
                {
                    Accumulation_charts.Legend = new ChartLegend()
                    {
                        CornerRadius    = new CornerRadius(0),
                        FontSize        = 15,
                        DockPosition    = ChartDock.Right,
                        BorderThickness = new Thickness(1)
                    };
                }

                DoughnutSeries     series1        = new DoughnutSeries();
                ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo();

                ChartLegend1.Visibility = Visibility.Visible;

                DataTemplate template1 = MainGrid.Resources["labeltemplate"] as DataTemplate;
                adornmentInfo1.ShowLabel     = true;
                adornmentInfo1.LabelTemplate = template1;

                series1.XBindingPath   = "CompanyName";
                series1.YBindingPath   = "CompanyTurnover";
                series1.ItemsSource    = viewModel.CompanyDetails;
                series1.AdornmentsInfo = adornmentInfo1;

                Accumulation_charts.Series.Clear();
                Accumulation_charts.Header = "Top car company's turnover";
                Accumulation_charts.Series.Add(series1);
            }
            if (comboBox.SelectedIndex == 4 && viewModel != null)
            {
                DoughnutSeries series1 = new DoughnutSeries();
                DoughnutSeries series2 = new DoughnutSeries();
                DoughnutSeries series3 = new DoughnutSeries();

                ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo();
                ChartAdornmentInfo adornmentInfo2 = new ChartAdornmentInfo();
                ChartAdornmentInfo adornmentInfo3 = new ChartAdornmentInfo();

                ChartColorModel color1 = new ChartColorModel();
                ChartColorModel color2 = new ChartColorModel();
                ChartColorModel color3 = new ChartColorModel();

                color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73)));
                color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84)));
                color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119)));

                color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73)));
                color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73)));
                color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84)));
                color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84)));
                color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119)));
                color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119)));

                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119)));
                color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119)));

                DataTemplate template1 = MainGrid.Resources["populationLabelTemplate1"] as DataTemplate;
                DataTemplate template2 = MainGrid.Resources["populationLabelTemplate2"] as DataTemplate;
                DataTemplate template3 = MainGrid.Resources["populationLabelTemplate3"] as DataTemplate;

                ChartLegend1.Visibility = Visibility.Collapsed;

                adornmentInfo1.ShowLabel           = true;
                adornmentInfo1.SegmentLabelContent = LabelContent.LabelContentPath;
                adornmentInfo1.LabelTemplate       = template1;

                adornmentInfo2.ShowLabel           = true;
                adornmentInfo2.SegmentLabelContent = LabelContent.LabelContentPath;
                adornmentInfo2.LabelTemplate       = template2;

                adornmentInfo3.ShowLabel           = true;
                adornmentInfo3.SegmentLabelContent = LabelContent.LabelContentPath;
                adornmentInfo3.LabelTemplate       = template3;

                series1.ItemsSource         = viewModel.Population;
                series1.XBindingPath        = "Continent";
                series1.YBindingPath        = "PopulationinContinents";
                series1.AdornmentsInfo      = adornmentInfo1;
                series1.Stroke              = new SolidColorBrush(Colors.White);
                series1.DoughnutCoefficient = 1;
                series1.DoughnutSize        = 1;
                series1.Label      = "Continents";
                series1.Palette    = ChartColorPalette.Custom;
                series1.ColorModel = color1;

                series2.ItemsSource         = viewModel.Population;
                series2.XBindingPath        = "Countries";
                series2.YBindingPath        = "PopulationinCountries";
                series2.AdornmentsInfo      = adornmentInfo2;
                series2.Stroke              = new SolidColorBrush(Colors.White);
                series2.DoughnutCoefficient = 1;
                series2.DoughnutSize        = 1;
                series2.Label      = "Countries";
                series2.Palette    = ChartColorPalette.Custom;
                series2.ColorModel = color2;

                series3.ItemsSource         = viewModel.Population;
                series3.XBindingPath        = "States";
                series3.YBindingPath        = "PopulationinStates";
                series3.AdornmentsInfo      = adornmentInfo3;
                series3.Stroke              = new SolidColorBrush(Colors.White);
                series3.DoughnutCoefficient = 1;
                series3.DoughnutSize        = 1;
                series3.Label      = "States";
                series3.Palette    = ChartColorPalette.Custom;
                series3.ColorModel = color3;

                Accumulation_charts.Header = "Most populated continents";
                Accumulation_charts.Series.Clear();
                Accumulation_charts.Series.Add(series1);
                Accumulation_charts.Series.Add(series2);
                Accumulation_charts.Series.Add(series3);
            }
            if (comboBox.SelectedIndex == 5 && viewModel != null)
            {
                DoughnutSeries     series1        = new DoughnutSeries();
                ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo();

                ChartLegend1.Visibility = Visibility.Collapsed;

                adornmentInfo1.ShowLabel           = true;
                adornmentInfo1.ShowConnectorLine   = true;
                adornmentInfo1.UseSeriesPalette    = true;
                adornmentInfo1.ConnectorHeight     = 37;
                adornmentInfo1.SegmentLabelContent = LabelContent.Percentage;
                adornmentInfo1.SegmentLabelFormat  = "##.#";

                series1.XBindingPath      = "Utilization";
                series1.YBindingPath      = "ResponseTime";
                series1.StartAngle        = 180;
                series1.EndAngle          = 360;
                series1.EnableSmartLabels = true;
                series1.LabelPosition     = CircularSeriesLabelPosition.Outside;
                series1.Margin            = new Thickness(0, 25, 0, 0);
                series1.ItemsSource       = viewModel.Metric;
                series1.AdornmentsInfo    = adornmentInfo1;

                Accumulation_charts.Header = "Application Performance Metrics";
                Accumulation_charts.Series.Clear();
                Accumulation_charts.Series.Add(series1);
            }
            if (comboBox.SelectedIndex == 6 && viewModel != null)
            {
                DoughnutSeries doughnutSeries = new DoughnutSeries();
                doughnutSeries.DataContext         = viewModel;
                doughnutSeries.XBindingPath        = "XValue";
                doughnutSeries.YBindingPath        = "YValue";
                doughnutSeries.ItemsSource         = (doughnutSeries.DataContext as PieChartViewModel).DoughnutSeriesData;
                doughnutSeries.IsStackedDoughnut   = true;
                doughnutSeries.EnableAnimation     = true;
                doughnutSeries.LegendIcon          = ChartLegendIcon.Circle;
                doughnutSeries.StartAngle          = -90;
                doughnutSeries.EndAngle            = 270;
                doughnutSeries.SegmentSpacing      = 0.2;
                doughnutSeries.DoughnutCoefficient = 0.8;
                doughnutSeries.CapStyle            = DoughnutCapStyle.BothCurve;
                doughnutSeries.MaximumValue        = 100;

                var colorModel    = new ChartColorModel();
                var customBrushes = new List <Brush>();
                customBrushes.Add(new SolidColorBrush(Color.FromArgb(0xFF, 0x47, 0xBA, 0x9F)));
                customBrushes.Add(new SolidColorBrush(Color.FromArgb(0xFF, 0xE5, 0x88, 0x70)));
                customBrushes.Add(new SolidColorBrush(Color.FromArgb(0xFF, 0x96, 0x86, 0xC9)));
                customBrushes.Add(new SolidColorBrush(Color.FromArgb(0xFF, 0xE5, 0x65, 0x90)));

                colorModel.CustomBrushes  = customBrushes;
                doughnutSeries.ColorModel = colorModel;
                doughnutSeries.Palette    = ChartColorPalette.Custom;
                var image = new Image()
                {
                    Source = new BitmapImage(new Uri("ms-appx:///Chart/Tutorials/ChartSamples/PieChart/Images/Person.png", UriKind.RelativeOrAbsolute))
                };
                var centerView = new ContentControl()
                {
                    Content = image, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center
                };

                var binding = new Binding();
                binding.Source             = doughnutSeries;
                binding.Path               = new PropertyPath("InnerRadius");
                binding.Converter          = new ImageSizeConverter();
                binding.ConverterParameter = doughnutSeries;
                binding.Mode               = BindingMode.TwoWay;
                centerView.SetBinding(ContentControl.WidthProperty, binding);
                centerView.SetBinding(ContentControl.HeightProperty, binding);
                doughnutSeries.CenterView = centerView;

                var legend = new ChartLegend()
                {
                    DockPosition = ChartDock.Bottom
                };
                legend.ItemTemplate = MainGrid.Resources["stackedDoughnutTemplate"] as DataTemplate;

                Accumulation_charts.Legend = legend;
                Accumulation_charts.Series.Clear();
                Accumulation_charts.Series.Add(doughnutSeries);
                Accumulation_charts.Header = "Percentage of Loan Closure";
            }
            if (comboBox.SelectedIndex == 7 && viewModel != null)
            {
                PyramidSeries      series1        = new PyramidSeries();
                ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo();

                ChartLegend1.Visibility = Visibility.Collapsed;

                DataTemplate template1 = MainGrid.Resources["labelTemplate"] as DataTemplate;
                adornmentInfo1.ShowLabel     = true;
                adornmentInfo1.LabelTemplate = template1;

                series1.XBindingPath   = "CompanyName";
                series1.YBindingPath   = "CompanyTurnover";
                series1.ItemsSource    = viewModel.CompanyDetails;
                series1.AdornmentsInfo = adornmentInfo1;
                series1.Margin         = new Thickness(20, 0, 20, 20);

                Accumulation_charts.Header = "Top car company's turnover";
                Accumulation_charts.Margin = new Thickness(20, 20, 20, 20);
                Accumulation_charts.Series.Clear();
                Accumulation_charts.Series.Add(series1);
            }
            if (comboBox.SelectedIndex == 8 && viewModel != null)
            {
                FunnelSeries       series1        = new FunnelSeries();
                ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo();

                ChartLegend1.Visibility = Visibility.Collapsed;

                DataTemplate template1 = MainGrid.Resources["labelTemplate"] as DataTemplate;
                adornmentInfo1.ShowLabel     = true;
                adornmentInfo1.LabelTemplate = template1;

                series1.XBindingPath   = "CompanyName";
                series1.YBindingPath   = "CompanyTurnover";
                series1.ItemsSource    = viewModel.CompanyDetails;
                series1.AdornmentsInfo = adornmentInfo1;
                series1.Margin         = new Thickness(20, 0, 20, 20);

                Accumulation_charts.Header = "Top car company's turnover";
                Accumulation_charts.Margin = new Thickness(20, 20, 20, 20);
                Accumulation_charts.Series.Clear();
                Accumulation_charts.Series.Add(series1);
            }
        }
        public void SetUp()
        {
            _dataTemplate = new DataTemplate();

            _selector = new FilterDataTemplateSelector();
        }
Exemplo n.º 57
0
        public static TreeViewItem AddObject <T>(this PresentationFrameworkCollection <object> items, T t, DataTemplate template)
        {
            TreeViewItem treeViewItem = new TreeViewItem();

            treeViewItem.HeaderTemplate = template;
            treeViewItem.Header         = t;
            treeViewItem.DataContext    = t;
            treeViewItem.Loaded        += new RoutedEventHandler(treeViewItem_Loaded);
            items.Add(treeViewItem);
            return(treeViewItem);
        }
Exemplo n.º 58
0
        public static List <TreeViewItem> AddObjectList <T>(this PresentationFrameworkCollection <object> items, List <T> listofT, DataTemplate template)
        {
            List <TreeViewItem> treeViewItemList = new List <TreeViewItem>();

            listofT.ForEach(t =>
            {
                TreeViewItem treeViewItem = items.AddObject <T>(t, template);
                treeViewItemList.Add(treeViewItem);
            });
            return(treeViewItemList);
        }
 public ChatTemplateSelector()
 {
     this.incomingDataTemplate = new DataTemplate(typeof(IncomingViewCell));
     this.outgoingDataTemplate = new DataTemplate(typeof(OutgoingViewCell));
 }
Exemplo n.º 60
0
 public LayoutModeMapping(Design design, RadioButton radioButton, RadioButton stickyRadioButton, string visualStateName, DataTemplate template)
 {
     Design            = design;
     RadioButton       = radioButton;
     StickyRadioButton = stickyRadioButton;
     VisualStateName   = visualStateName;
     Template          = template;
 }