public override void AddUI(Grid grid)
        {
            if (Config != null && Config.ShownAtRunTime)
            {
                grid.RowDefinitions.Add(new RowDefinition());
                #region
                StackPanel g = new StackPanel() { Orientation = System.Windows.Controls.Orientation.Horizontal, Margin=new Thickness(5,0,0,0) };

                TextBlock lblUrl = new TextBlock() { VerticalAlignment = System.Windows.VerticalAlignment.Center, Margin = new Thickness(2) };
                lblUrl.Text = Resources.Strings.LabelUrl;
                g.Children.Add(lblUrl);

                TextBox tbFormat = new TextBox() { Margin = new Thickness(4,2,0,2), Width = 50, MaxWidth= 60 };
                TextBox tb = new TextBox() { 
                    Margin = new Thickness(2), 
                    HorizontalAlignment = HorizontalAlignment.Stretch
                };
                tb.SetValue(ToolTipService.ToolTipProperty, Config.ToolTip);
                if (value != null)
                    tb.Text = value.Url.ToString();

                tb.TextChanged += (s, e) =>
                {
                    if (value == null)
                        Value = new GPRasterData(Config.Name, tb.Text, tbFormat.Text) { Format = tbFormat.Text };//Workaround for slapi bug
                    else
                        value.Url = tb.Text;
                    RaiseCanExecuteChanged();
                };
                g.Children.Add(tb);

                TextBlock lbl = new TextBlock() { VerticalAlignment = System.Windows.VerticalAlignment.Center, Margin = new Thickness(2) };
                lbl.Text = Resources.Strings.LabelFormat;
                g.Children.Add(lbl);

                if (Config is RasterDataParameterConfig)
                    tbFormat.SetValue(ToolTipService.ToolTipProperty, (Config as RasterDataParameterConfig).FormatToolTip);
                if (value != null)
                    tbFormat.Text = value.Format.ToString();
                tbFormat.TextChanged += (s, e) =>
                {
                    if (value == null)
                        Value = new GPRasterData(Config.Name, tb.Text, tbFormat.Text) { Format = tbFormat.Text };//Workaround for slapi bug
                    else
                        value.Format = tbFormat.Text;
                    RaiseCanExecuteChanged();
                };
                g.Children.Add(tbFormat);

                g.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                g.SetValue(Grid.ColumnProperty, 0);
                g.SetValue(Grid.ColumnSpanProperty, 2);
                grid.Children.Add(g);
                RaiseCanExecuteChanged();
                #endregion
            }
        }
Пример #2
0
        private void MostrarGrade()
        {
            TxtCurso.Text = Context.Grade.NomeCurso;
            TxtDia.Text = Context.Grade.NomeDia;
            TxtSemestre.Text = Context.Grade.NumeroSemestre.ToString();

            for (int i = 0; i < Context.Grade.Horarios.Count; i++)
            {
                if (i > 0 && Context.Grade.Horarios[i].HorarioInicial != Context.Grade.Horarios[i - 1].HorarioFinal)
                {
                    Tabela.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
                    var intervalo = new TextBlock()
                    {
                        Text = "Intervalo",
                        TextAlignment = System.Windows.TextAlignment.Center,
                        Background = Brushes.LightGray,
                        Width = Tabela.Width,
                        VerticalAlignment = System.Windows.VerticalAlignment.Center,
                        HorizontalAlignment = System.Windows.HorizontalAlignment.Center
                    };
                    intervalo.SetValue(Grid.ColumnSpanProperty, 2);
                    intervalo.SetValue(Grid.RowProperty, Tabela.RowDefinitions.Count - 1);
                    Tabela.Children.Add(intervalo);
                }

                Tabela.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50) });
                var horario = new TextBlock()
                {
                    Text = string.Concat(Context.Grade.Horarios[i].HorarioInicial, " - ", Context.Grade.Horarios[i].HorarioFinal),
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Center
                };
                horario.SetValue(Grid.ColumnProperty, 0);
                horario.SetValue(Grid.RowProperty, Tabela.RowDefinitions.Count - 1);

                var materia = new StackPanel()
                {
                    Orientation = Orientation.Vertical,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Center
                };
                if (Context.Grade.Horarios[i].Materia != null)
                {
                    materia.Children.Add(new TextBlock() { Text = Context.Grade.Horarios[i].Materia.Materia, FontWeight = FontWeight.FromOpenTypeWeight(600) });
                    materia.Children.Add(new TextBlock() { Text = Context.Grade.Horarios[i].Materia.Professor });
                }
                materia.SetValue(Grid.ColumnProperty, 1);
                materia.SetValue(Grid.RowProperty, Tabela.RowDefinitions.Count - 1);

                Tabela.Children.Add(horario);
                Tabela.Children.Add(materia);
            }
        }
 public override void AddUI(Grid grid)
 {
     if (Config != null && Config.ShownAtRunTime && Map != null)
     {
         #region
         ParameterSupport.FeatureLayerParameterConfig flConfig = Config as ParameterSupport.FeatureLayerParameterConfig;
         #region Get layer list
         List<GraphicsLayer> inputLayers = GetLayerList();
         #endregion
         Map.Layers.CollectionChanged -= Layers_CollectionChanged;
         Map.Layers.CollectionChanged += Layers_CollectionChanged;
         layerPanel = new StackPanel();
         layerPanel.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
         layerPanel.SetValue(Grid.ColumnProperty, 1);
         grid.Children.Add(layerPanel);
         populateLayerPanel(inputLayers);
         #endregion
     }
 }
Пример #4
0
 private void SetChoices(Platform platform)
 {
     if ( dynamicStackPanel != null )
         dynamicStackPanel.Children.Clear();
     dynamicStackPanel = new StackPanel();
     dynamicStackPanel.Orientation = Orientation.Horizontal;
     dynamicStackPanel.SetValue(Grid.RowProperty, 1);
     dynamicStackPanel.SetValue(Grid.ColumnProperty, 3);
     if (platform == Platform.Desktop)
     {
         CheckBox cb = new CheckBox();
         cb.Content = "Winforms";
         cb.Height = 30;
         cb.Width = 90;
         dynamicStackPanel.Children.Add(cb);
         cb = new CheckBox();
         cb.Content = "WPF";
         cb.Height = 30;
         cb.Width = 50;
         dynamicStackPanel.Children.Add(cb);
     }
     else
     {
         CheckBox cb = new CheckBox();
         cb.Content = "AJAX";
         cb.Height = 30;
         cb.Width = 60;
         dynamicStackPanel.Children.Add(cb);
         cb = new CheckBox();
         cb.Content = "Silverlight";
         cb.Height = 30;
         cb.Width = 90;
         dynamicStackPanel.Children.Add(cb);
     }
     LayoutRoot.Children.Add(dynamicStackPanel);
 }
Пример #5
0
        public static UIElement MakeListItem(MyroConfigFiles myroConfig)
        {
            Grid s1 = new Grid() { HorizontalAlignment = HorizontalAlignment.Stretch };
            s1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            s1.ColumnDefinitions.Add(new ColumnDefinition());
            StackPanel s2 = new StackPanel()
            {
                VerticalAlignment = VerticalAlignment.Center,
                Orientation = Orientation.Vertical
            };
            s2.SetValue(Grid.ColumnProperty, 1);
            Label l1 = new Label()
            {
                Content = myroConfig.BaseName,
                Padding = new Thickness(0, 0, 5, 0)
            };
            Label l2 = new Label()
            {
                Content =
                    myroConfig.MyroConfigExisted ?
                    myroConfig.MyroConfiguration.FriendlyName :
                    "No Myro configuration",
                Padding = new Thickness(0, 0, 5, 0)
            };
            Image i = new Image()
            {
                VerticalAlignment = VerticalAlignment.Center,
                Width = 64,
                Height = 64,
                Margin = new Thickness(2, 2, 3, 2),
                Stretch = Stretch.Uniform
            };
            i.SetValue(Grid.ColumnProperty, 0);
            if (myroConfig.IconFilePath != null)
                i.Source = new BitmapImage(new Uri("file://" + myroConfig.IconFilePath));

            s2.Children.Add(l1);
            s2.Children.Add(l2);
            s1.Children.Add(i);
            s1.Children.Add(s2);

            return s1;
        }
Пример #6
0
        public ScrollbackArea(UserControl Parent)
        {
            _dock = new DockPanel();

            StackPanel sp = new StackPanel();
            sp.Orientation = Orientation.Horizontal;
            _dock.Children.Add(sp);

            sp.SetValue(DockPanel.DockProperty, Dock.Top);

            Button bCopyText = new Button();
            bCopyText.Content = "Copy Text To Clipboard";
            bCopyText.Click += new RoutedEventHandler(bCopyText_Click);
            sp.Children.Add(bCopyText);

            Button bSaveRtf = new Button();
            bSaveRtf.Content = "Save RTF";
            bSaveRtf.Click += new RoutedEventHandler(bSaveRtf_Click);
            sp.Children.Add(bSaveRtf);

            Button bSaveText = new Button();
            bSaveText.Content = "Save Text";
            bSaveText.Click += new RoutedEventHandler(bSaveText_Click);
            sp.Children.Add(bSaveText);

            ScrollViewer sv = new ScrollViewer();
            _dock.Children.Add(sv);

            _RTB = new RichTextBox();
            _RTB.IsReadOnly = true;
            _RTB.IsReadOnlyCaretVisible = true;

            _doc = new FlowDocument();
            _RTB.Document = _doc;

            _parent = Parent;

            Reset();

            sv.Content =_RTB;
        }
Пример #7
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Grid grid = new Grid();
            RowDefinition rowDefinition = new RowDefinition();
            rowDefinition.Height = GridLength.Auto;
            grid.RowDefinitions.Add(rowDefinition);
            grid.RowDefinitions.Add(new RowDefinition());

            StackPanel panel = new StackPanel();
            panel.Orientation = Orientation.Horizontal;
            panel.SetValue(Grid.RowProperty, 0);

            InsertButton("Print", btnPrint_Click, panel);
            InsertButton("Close", btnClose_Click, panel);

            grid.Children.Add(panel);
            
            XamlFormatProvider provider = new XamlFormatProvider();
            string documentContent = provider.Export(this.radRichTextBox.Document);

            RadRichTextBox rtb = new RadRichTextBox();
            rtb.Document = provider.Import(documentContent);
            rtb.IsReadOnly = true;
            rtb.IsFocusable = false;
            rtb.IsSelectionEnabled = false;
            rtb.IsContextMenuEnabled = false;
            rtb.IsSelectionMiniToolBarEnabled = false;
            rtb.SetValue(Grid.RowProperty, 1);

            grid.Children.Add(rtb);

            window.Height = 100;
            window.Width = 100;
            this.window.WindowState = WindowState.Maximized;
            this.window.Content = grid;
            this.window.Show();
        }
Пример #8
0
        /// <summary>
        /// Load container for Zoom icons at the top-right corner of PlotArea
        /// </summary>
        protected void LoadZoomIcons()
        {
            _zoomIconContainer = new StackPanel();
            _zoomIconContainer.Orientation = Orientation.Horizontal;
            _zoomIconContainer.HorizontalAlignment = HorizontalAlignment.Right;
            _zoomIconContainer.VerticalAlignment = VerticalAlignment.Top;
            _zoomIconContainer.Margin = new Thickness(0, 3, 5, 0);
            _zoomIconContainer.SetValue(Canvas.ZIndexProperty, 95000);

            LoadZoomOutIcon();
            LoadSeparater();
            LoadShowAllIcon();

            _plotAreaGrid.Children.Add(_zoomIconContainer);
        }
Пример #9
0
        /// <summary>
        /// Load ToolBar at the top-right side corner of the chart.
        /// </summary>
        protected void LoadToolBar()
        {
            _toolbarContainer = new StackPanel();
            _toolbarContainer.Orientation = Orientation.Horizontal;
            _toolbarContainer.HorizontalAlignment = HorizontalAlignment.Right;
            _toolbarContainer.VerticalAlignment = VerticalAlignment.Top;
            _toolbarContainer.Margin = new Thickness(0, 3, 5, 0);
            _toolbarContainer.SetValue(Canvas.ZIndexProperty, 90000);

            LoadWm();
            LoadSaveIcon();
            
            _rootElement.Children.Add(_toolbarContainer);
        }
Пример #10
0
        /// <summary>
        /// Creates Look behind column.
        /// </summary>
        private void CreateLookBehindColumns()
        {
            if (this.lookBehindCellTemplate == null)
            {
                throw new ArgumentNullException("Look behind cell template must be defined", (Exception)null);
            }

            if (this.lookBehindSummaryCellTemplate == null)
            {
                throw new ArgumentNullException("Look behind summary cell template must be defined", (Exception)null);
            }

            this.lookBehindView = new LookBehindView();
            this.lookBehindColumn = new ColumnManager();
            Grid lookBehindLayout = DataTemplateHelper.LoadContent((this.layoutRoot.Resources["LookBehindCellTemplateGridLayout"] as DataTemplate)) as Grid;
            lookBehindLayout.SetValue(Grid.ColumnSpanProperty, this.WrapDataGridColumns.Count + 1);
            DataTemplate cellTemplate = this.layoutRoot.Resources["LookBehindCellTemplate"] as DataTemplate;
            StackPanel summaryPanel = new StackPanel();
            summaryPanel.SetValue(Grid.RowProperty, 0);
            summaryPanel.SetValue(Grid.ColumnProperty, 0);

            StackPanel columnPanel = new StackPanel();
            columnPanel.HorizontalAlignment = HorizontalAlignment.Right;
            columnPanel.Orientation = Orientation.Horizontal;
            columnPanel.SetValue(Grid.RowProperty, 0);
            columnPanel.SetValue(Grid.ColumnProperty, 1);

            SummaryManager summary = new SummaryManager();
            summary.CellTemplate = this.lookBehindSummaryCellTemplate;
            summary.MainPanel = summaryPanel;

            this.lookBehindColumn.SetValue(Grid.ColumnSpanProperty, 5);
            this.lookBehindColumn.MasterCellTemplate = cellTemplate;
            this.lookBehindColumn.CellTemplate = this.lookBehindCellTemplate;
            this.lookBehindColumn.StackPanel = columnPanel;
            this.lookBehindColumn.SummaryManager = summary;
            this.lookBehindColumn.GridLayout = lookBehindLayout;
        }
        public void Apply()
        {
            panel.Children.RemoveRange(0, panel.Children.Count - 1);

            int i = 0;
            foreach (var language in Configuration.Languages.OrderBy(e => e.Culture.EnglishName))
            {
                var lang = language;
                var index = i++;
                var checkbox = new CheckBox();
                checkbox.IsChecked = lang.Enabled;
                checkbox.IsThreeState = false;
                checkbox.Content = lang.Culture.EnglishName;
                var delete = new Button();
                delete.Style = (Style)panel.Resources["ImageButton"];
                delete.Content = Image("Resources/cancel.gif", "Delete this language entry.");
                delete.Margin = new Thickness(0, 0, 8, 0);

                var stack = new StackPanel();
                stack.Orientation = Orientation.Horizontal;
                stack.Children.Add(delete);
                stack.Children.Add(checkbox);

                var defaultDict = new System.Windows.Controls.Primitives.ToggleButton();
                defaultDict.IsThreeState = false;
                if (!lang.HasStandardDictionary) defaultDict.Visibility = System.Windows.Visibility.Hidden;
                defaultDict.IsChecked = lang.CustomDictionaries.Contains("*");
                defaultDict.Content = Image("Resources/anchor.png", "Use the standard dictionary.");

                var customDict = new System.Windows.Controls.Primitives.ToggleButton();
                customDict.IsThreeState = false;
                customDict.IsChecked = lang.CustomDictionaries.Any(d => d != "*");
                customDict.Content = Image("Resources/book_open.png", "Use custom dictionaries.");

                var rightstack = new StackPanel();
                rightstack.Orientation = Orientation.Horizontal;
                rightstack.HorizontalAlignment = HorizontalAlignment.Right;
                rightstack.Children.Add(defaultDict);
                rightstack.Children.Add(customDict);

                var dock = new DockPanel();
                stack.SetValue(DockPanel.DockProperty, Dock.Left);
                rightstack.SetValue(DockPanel.DockProperty, Dock.Right);
                dock.Children.Add(stack);
                dock.Children.Add(rightstack);
                dock.Background = new SolidColorBrush(Color.FromRgb(0xff, 0xff, 0xff));
                dock.Opacity = 0.88;

                checkbox.Click += (sender, args) =>
                {
                    lang.Enabled = checkbox.IsChecked ?? false;
                };

                delete.Click += (sender, args) =>
                {
                    Configuration.Languages.Remove(lang);
                    panel.Children.Remove(dock);
                };

                defaultDict.Click += (sender, args) =>
                {
                    var has = lang.CustomDictionaries.Any(d => d == "*");
                    if (has != (defaultDict.IsChecked ?? false))
                    {
                        if (!has) lang.CustomDictionaries.Add("*");
                        else lang.CustomDictionaries.Remove("*");
                    }
                };

                customDict.Click += (sender, args) =>
                {
                    if (customDict.IsChecked ?? false)
                    {
                        // show file dialog to select custom dictionary files.
                        var d = new System.Windows.Forms.OpenFileDialog();
                        d.Title = "Select Custom Dictionary Files for " + lang.Culture.EnglishName;
                        d.SupportMultiDottedExtensions = true;
                        d.Multiselect = true;
                        d.Filter = "Dictionary Files (*.lex;*.txt;*.dic)|*.lex;*.txt;*.dic|All files (*.*)|*.*";
                        d.ShowDialog();
                        foreach (var file in d.FileNames)
                        {
                            var newfile = System.IO.Path.Combine(Configuration.ConfigDirectory, System.IO.Path.GetFileName(file));
                            var ext = System.IO.Path.GetExtension(file);
                            if (ext == ".dic")
                            { // import dic files from NetSpell & ISpell
                                newfile = Configuration.ImportDic(file);
                            } else
                            {
                                System.IO.File.Copy(file, newfile);
                            }
                            lang.CustomDictionaries.Add(System.IO.Path.GetFileName(newfile));
                        }
                    } else
                    {
                        foreach (var customd in lang.CustomDictionaries.Where(d => d != "*").ToList())
                        {
                            var file = System.IO.Path.Combine(Configuration.ConfigDirectory, customd);
                            if (File.Exists(file)) File.Delete(file);
                            lang.CustomDictionaries.Remove(customd);
                        }
                    }
                };

                panel.Children.Insert(index, dock);
            }
        }
Пример #12
0
        private void GetAllTimeHighCompleted(object sender, GetHighscoresCompletedEventArgs e)
        {
            if (e.Result != null)
            {
                var grid = (Grid) _dialog.DialogContents.Content;
                var panel = new StackPanel();
                panel.SetValue(Grid.RowProperty, 0);
                panel.SetValue(Grid.ColumnProperty, 0);
                grid.Children.Add(panel);

                var header = new TextBlock
                                 {
                                     Style = Styles.StrongText,
                                     Margin = new Thickness(0, 0, 0, 5),
                                     Text = Strings.HighScoreAllTime
                                 };
                panel.Children.Add(header);

                int place = 1;
                foreach (DataItem score in e.Result)
                {
                    AddHighScore(panel, place, score.Name, score.Value);
                    place++;
                }
            }
            var statistics = new StatisticsClient();
            statistics.GetHighscoresCompleted += GetMonthHighCompleted;
            statistics.GetHighscoresAsync(Game.HighScore, new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1),
                                          null);
        }
Пример #13
0
        private Grid createGridLayout(double width, double height, out Grid grid, out TextBlock page)
        {
            grid=new Grid();
            Grid layout=new Grid();
            layout.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            layout.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            layout.Width = width;
            layout.Height = width;
            layout.Children.Add(grid);
            grid.RowDefinitions.Add(new RowDefinition());
            grid.RowDefinitions.Add(new RowDefinition());
            grid.RowDefinitions.Add(new RowDefinition());
            grid.RowDefinitions[0].Height = new GridLength(50, GridUnitType.Pixel);
            grid.RowDefinitions[2].Height = new GridLength(15, GridUnitType.Pixel);
            grid.RowDefinitions[1].Height = new GridLength(height - 65, GridUnitType.Pixel);

            StackPanel headerPanel=new StackPanel();
            headerPanel.Height = 50;
            headerPanel.Background = new SolidColorBrush(Colors.LightGray);
            TextBlock header=new TextBlock();
            //header.Text = String.Format("{0} на {1}", GlobalStatus.Current.HomeHeader,DateTime.Now.ToString("dd.MM.yy HH:mm"));
            header.Text = "";
            header.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            header.FontSize = 13;
            headerPanel.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            grid.Children.Add(headerPanel);
            headerPanel.Children.Add(header);
            headerPanel.SetValue(Grid.RowProperty, 0);

            //host.Measure(new Size(width, double.PositiveInfinity));

            Grid footerGrid=new Grid();
            footerGrid.Height = 15;
            footerGrid.Background = new SolidColorBrush(Colors.LightGray);
            footerGrid.ColumnDefinitions.Add(new ColumnDefinition());
            footerGrid.ColumnDefinitions.Add(new ColumnDefinition());
            footerGrid.ColumnDefinitions.Add(new ColumnDefinition());
            footerGrid.ColumnDefinitions[0].Width = GridLength.Auto;
            footerGrid.ColumnDefinitions[1].Width = new GridLength(1, GridUnitType.Star);
            footerGrid.ColumnDefinitions[2].Width = GridLength.Auto;
            footerGrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;

            TextBlock footer=new TextBlock();
            footer.Text = String.Format("{0} на {1} ", GlobalStatus.Current.HomeHeader, DateTime.Now.ToString("HH:mm")); ;
            footer.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            footer.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            footer.FontSize = 12;
            footerGrid.Children.Add(footer);
            footer.SetValue(Grid.ColumnProperty, 1);

            page=new TextBlock();
            page.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            page.TextAlignment = TextAlignment.Left;
            page.FontSize = 12;
            footerGrid.Children.Add(page);
            page.SetValue(Grid.ColumnProperty, 0);

            TextBlock podp=new TextBlock();
            podp.Text = String.Format("{0}",  DateTime.Now.ToString("dd.MM.yy"));
            podp.TextAlignment = TextAlignment.Right;
            podp.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            podp.FontSize = 12;
            footerGrid.Children.Add(podp);
            podp.SetValue(Grid.ColumnProperty, 2);

            grid.Children.Add(footerGrid);
            footerGrid.SetValue(Grid.RowProperty, 2);

            return layout;
        }
Пример #14
0
		protected virtual void ImplantImage(double width, double height)
		{
			_img.Height = _editBox.ActualHeight;
			_img.Margin = _editBox.Margin;
			_img.Stretch = Stretch.Uniform;

			var parent = _editBox.Parent;

			var stackPanel = new StackPanel();
			stackPanel.Orientation = Orientation.Horizontal;
			stackPanel.Children.Add(_img);
			// stackPanel.Children.Add(_editBox); // this must be postponed here, since _editBox is still into the hierarchy

			if (parent is ContentControl)
			{
				((ContentControl)parent).Content = stackPanel;
			}
			else if (parent is Decorator)
			{
				((Decorator)parent).Child = stackPanel;
			}
			else if (parent is Panel)
			{
				var panel = (Panel)parent;
				var idx = panel.Children.IndexOf(_editBox);
				if (idx < 0)
					throw new InvalidOperationException(string.Format("The parent of the EditBox is a {0}, but the parent's children collection does not contain the EditBox", panel.GetType()));
				panel.Children.RemoveAt(idx);
				panel.Children.Insert(idx, stackPanel);
			}
			else
			{
				var stb = new StringBuilder();
				stb.AppendFormat("Unexpected location of the EditBox within {0}", this.ToString());
				stb.AppendLine();
				stb.AppendFormat("The parent of the editbox is {0}", _editBox.Parent.ToString());
				stb.AppendLine();
				stb.AppendLine("The hierarchy of childs is as follows:");
				PrintVisualChilds(this, 0, stb);
				throw new ApplicationException(stb.ToString());
			}

			stackPanel.Children.Add(_editBox);

			// now some special properties
			if (parent is Grid)
			{
				foreach (DependencyProperty dp in new DependencyProperty[] { Grid.RowProperty, Grid.ColumnProperty, Grid.RowSpanProperty, Grid.ColumnSpanProperty })
				{
					stackPanel.SetValue(dp, _editBox.GetValue(dp));
				}
			}
			if (parent is DockPanel)
			{
				stackPanel.SetValue(DockPanel.DockProperty, _editBox.GetValue(DockPanel.DockProperty));
			}

			/*

			if (_editBox.Parent is Grid) // most Windows version have the TextBox located inside a Grid
			{
				var grid = _editBox.Parent as Grid;
				_imgColumnDefinition = new ColumnDefinition();
				_imgColumnDefinition.Width = new GridLength(1, GridUnitType.Auto);
				grid.ColumnDefinitions.Insert(0, _imgColumnDefinition);
				foreach (UIElement ele in grid.Children)
				{
					if (ele is TextBox || ele is System.Windows.Controls.Primitives.ToggleButton)
					{
						ele.SetValue(Grid.ColumnProperty, 1 + (int)ele.GetValue(Grid.ColumnProperty));
					}
					else
					{
						ele.SetValue(Grid.ColumnSpanProperty, 1 + (int)ele.GetValue(Grid.ColumnSpanProperty));
					}
				}
				grid.Children.Add(_img);
			}
			else if (_editBox.Parent is DockPanel) // Some Windows XP versions have the TextBox sitting in a DockPanel instead of a Grid
			{
				var dockp = _editBox.Parent as DockPanel;
				var list = new List<UIElement>();
				foreach (UIElement child in dockp.Children) // collect the original children temporary in a list
					list.Add(child);

				dockp.Children.Clear(); // clear the children, because we need to dock them again

				_img.SetValue(DockPanel.DockProperty, Dock.Left);
				dockp.Children.Add(_img); // add the image to the left side
				foreach (UIElement child in list) // now dock the original children again
					dockp.Children.Add(child);
			}
			else
			{
				var stb = new StringBuilder();
				stb.AppendFormat("Unexpected location of grid within {0}", this.ToString());
				stb.AppendLine();
				stb.AppendFormat("The parent of the editbox is {0}", _editBox.Parent.ToString());
				stb.AppendLine();
				stb.AppendLine("The hierarchy of childs is as follows:");
				PrintVisualChilds(this, 0, stb);
				throw new ApplicationException(stb.ToString());
			}

			*/
		}
Пример #15
0
        /// <summary>
        /// Creates a grouping column.        
        /// </summary>
        private void CreateGroupingColumn()
        {
            ColumnManager column = new ColumnManager();

            // Load our cell template, then the ISV cell template and set grid column/row properties to isv cell template.
            DataTemplate cellTemplate = this.layoutRoot.Resources["GroupingColumnTemplate"] as DataTemplate;
            Grid headerTemplate = DataTemplateHelper.LoadContent(this.layoutRoot.Resources["GroupingHeaderTemplate"] as DataTemplate) as Grid;
            headerTemplate.SetValue(Grid.RowProperty, 1);
            headerTemplate.SetValue(Grid.ColumnProperty, 0);

            // Column manager stack panel.
            StackPanel columnStackPanel = new StackPanel();
            columnStackPanel.SetValue(Canvas.ZIndexProperty, 9999);
            columnStackPanel.SetValue(Grid.ColumnProperty, 0);
            columnStackPanel.SetValue(Grid.RowProperty, 4);

            // Set column manager properties.
            column.MasterCellTemplate = null;
            column.CellTemplate = cellTemplate;
            column.ColumnHeader = headerTemplate;
            column.StackPanel = columnStackPanel;

            // Add Column manager to column manager collection
            this.mainViewColumns.Add(column);
        }
Пример #16
0
        /// <summary>
        /// Render a singleton item into a ListBoxItem
        /// </summary>
        /// <param name="item">Item to render</param>
        /// <returns>ListBoxItem corresponding to the Item</returns>
        private ListBoxItem RenderItemAsSingleton(Item item)
        {
            // get the icon for the itemtype
            ItemType itemType = null;
            string icon = null;
            if (ItemType.ItemTypes.TryGetValue(item.ItemTypeID, out itemType))
                icon = itemType.Icon;

            FrameworkElement element;
            ListBoxItem listBoxItem = new ListBoxItem() { Tag = item };
            StackPanel sp = new StackPanel() { Margin = new Thickness(0, -5, 0, 0), Width = 432d };
            listBoxItem.Content = sp;

            // first line (priority icon, checkbox / icon, name)
            Grid itemLineOne = new Grid();
            itemLineOne.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            itemLineOne.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            itemLineOne.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
            itemLineOne.Children.Add(element = new Image() { Source = new BitmapImage(new Uri(item.PriorityIcon, UriKind.Relative)), Margin = new Thickness(0, 2, 0, 0) });
            element.SetValue(Grid.ColumnProperty, 0);
            // render a checkbox if has Complete field
            if (itemType != null && itemType.HasField(FieldNames.Complete))
            {
                itemLineOne.Children.Add(element = new CheckBox() { IsChecked = (item.Complete == null ? false : item.Complete), Tag = item.ID });
                element.SetValue(Grid.ColumnProperty, 1);
                ((CheckBox)element).Click += new RoutedEventHandler(checkBoxClickEvent);
            }
            else
            {
                // render an icon if one exists
                if (icon != null)
                {
                    if (icon.StartsWith("/Images/") == false && icon.StartsWith("http") == false && icon.StartsWith("www.") == false)
                        icon = "/Images/" + icon;
                    itemLineOne.Children.Add(element = new Image() { Source = new BitmapImage(new Uri(icon, UriKind.RelativeOrAbsolute)), Width = 48, Height = 48, Margin = new Thickness(5, 11, 16, 8) });
                    element.SetValue(Grid.ColumnProperty, 1);
                }
                // render a picture if one exists
                // this picture will layer on top of the existing icon - in case the picture is unavailable (e.g. disconnected)
                var picFV = item.GetFieldValue(FieldNames.Picture, false);
                if (picFV != null && !String.IsNullOrEmpty(picFV.Value))
                {
                    icon = picFV.Value;
                    if (icon.StartsWith("/Images/") == false && icon.StartsWith("http") == false && icon.StartsWith("www.") == false)
                        icon = "/Images/" + icon;
                    itemLineOne.Children.Add(element = new Image() { Source = new BitmapImage(new Uri(icon, UriKind.RelativeOrAbsolute)), Width = 48, Height = 48, Margin = new Thickness(5, 11, 16, 8) });
                    element.SetValue(Grid.ColumnProperty, 1);
                }
            }
            itemLineOne.Children.Add(element = new TextBlock()
            {
                Text = item.Name,
                Style = (Style)App.Current.Resources["PhoneTextLargeStyle"],
                Foreground = new SolidColorBrush(GetDisplayColor(item.NameDisplayColor)),
                Margin = new Thickness(0, 12, 0, 0)
            });
            element.SetValue(Grid.ColumnProperty, 2);
            sp.Children.Add(itemLineOne);

            // second line (duedate, tags)
            Grid itemLineTwo = new Grid();
            itemLineTwo.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            itemLineTwo.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
            itemLineTwo.Children.Add(element = new TextBlock()
            {
                Text = item.DueDisplay,
                FontSize = (double)App.Current.Resources["PhoneFontSizeNormal"],
                Foreground = new SolidColorBrush(GetDisplayColor(item.DueDisplayColor)),
                Margin = new Thickness(32, -17, 0, 0)
            });
            element.SetValue(Grid.ColumnProperty, 0);

            // render tag panel
            if (item.Tags != null)
            {
                StackPanel tagStackPanel = new StackPanel()
                {
                    Margin = new Thickness(32, -17, 0, 0),
                    Orientation = System.Windows.Controls.Orientation.Horizontal,
                    HorizontalAlignment = System.Windows.HorizontalAlignment.Right
                };
                tagStackPanel.SetValue(Grid.ColumnProperty, 1);
                foreach (var tag in item.Tags)
                {
                    HyperlinkButton button;
                    tagStackPanel.Children.Add(button = new HyperlinkButton()
                    {
                        ClickMode = ClickMode.Release,
                        Content = tag.Name,
                        FontSize = (double)App.Current.Resources["PhoneFontSizeNormal"],
                        Foreground = new SolidColorBrush(GetDisplayColor(App.ViewModel.Constants.LookupColor(tag.ColorID))),
                        Tag = tag.ID
                    });
                    button.Click += tagClickEvent;
                }
                itemLineTwo.Children.Add(tagStackPanel);
            }
            sp.Children.Add(itemLineTwo);

            // return the new ListBoxItem
            return listBoxItem;
        }
		void RebuildGrid()
		{
			if (this.marker != null) {
				AdornerLayer.GetAdornerLayer(this.buttonPanel).Remove(this.marker);
				AdornerLayer.GetAdornerLayer(this.dropPanel).Remove(this.marker);
				this.marker = null;
			}
			
			this.gridDisplay.Children.Clear();
			this.gridDisplay.RowDefinitions.Clear();
			this.gridDisplay.ColumnDefinitions.Clear();
			
			
			this.columnWidthGrid.ColumnDefinitions.Clear();
			this.columnWidthGrid.Children.Clear();
			
			this.rowHeightGrid.RowDefinitions.Clear();
			this.rowHeightGrid.Children.Clear();
			
			int rows = rowDefitions.Elements().Count();
			int cols = colDefitions.Elements().Count();
			
			if (rows == 0) {
				rowDefitions.Add(new XElement(rowDefName).AddAttribute("Height", "*"));
				rows = 1;
			}
			if (cols == 0) {
				colDefitions.Add(new XElement(colDefName).AddAttribute("Width", "*"));
				cols = 1;
			}
			
			for (int i = 0; i < cols; i++) {
				this.gridDisplay.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
				this.columnWidthGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
				GridLengthEditor editor = new GridLengthEditor(Orientation.Horizontal, i, (colDefitions.Elements().ElementAt(i).Attribute("Width") ?? new XAttribute("Width", "")).Value);
				
				editor.SelectedValueChanged += new EventHandler<GridLengthSelectionChangedEventArgs>(EditorSelectedValueChanged);
				editor.Deleted += new EventHandler<GridLengthSelectionChangedEventArgs>(EditorDeleted);
				editor.MouseLeftButtonDown += new MouseButtonEventHandler(EditorMouseLeftButtonDown);
				editor.Drop += new DragEventHandler(EditorDrop);
				editor.DragOver += new DragEventHandler(EditorDragOver);
				
				editor.AllowDrop = true;
				
				this.columnWidthGrid.Children.Add(editor);
				
				Button leftAddButton = new Button() {
					Content = "+",
					HorizontalAlignment = HorizontalAlignment.Left,
					Margin = new Thickness(-10, 10, 5,10),
					Padding = new Thickness(3),
					Tag = i
				};
				
				leftAddButton.Click += BtnAddColumnClick;
				
				leftAddButton.SetValue(Grid.ColumnProperty, i);
				this.columnWidthGrid.Children.Add(leftAddButton);
				
				if (cols == i + 1) {
					Button rightAddButton = new Button() {
						Content = "+",
						HorizontalAlignment = HorizontalAlignment.Right,
						Margin = new Thickness(5, 10, 0, 10),
						Padding = new Thickness(3)
					};
					
					rightAddButton.Click += BtnAddColumnClick;
					
					rightAddButton.SetValue(Grid.ColumnProperty, i);
					this.columnWidthGrid.Children.Add(rightAddButton);
				}
			}
			
			for (int i = 0; i < rows; i++) {
				this.gridDisplay.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
				
				this.rowHeightGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
				GridLengthEditor editor = new GridLengthEditor(Orientation.Vertical, i, (rowDefitions.Elements().ElementAt(i).Attribute("Height") ?? new XAttribute("Height", "")).Value);
				
				editor.SelectedValueChanged += new EventHandler<GridLengthSelectionChangedEventArgs>(EditorSelectedValueChanged);
				editor.Deleted += new EventHandler<GridLengthSelectionChangedEventArgs>(EditorDeleted);
				editor.MouseLeftButtonDown += new MouseButtonEventHandler(EditorMouseLeftButtonDown);
				editor.Drop += new DragEventHandler(EditorDrop);
				editor.DragOver += new DragEventHandler(EditorDragOver);
				
				editor.AllowDrop = true;
				
				this.rowHeightGrid.Children.Add(editor);
				
				Button topAddButton = new Button() {
					Content = "+",
					VerticalAlignment = VerticalAlignment.Top,
					Margin = new Thickness(10, -10, 10, 5),
					Padding = new Thickness(3),
					Tag = i
				};
				
				topAddButton.Click += BtnAddRowClick;
				
				topAddButton.SetValue(Grid.RowProperty, i);
				this.rowHeightGrid.Children.Add(topAddButton);
				
				if (rows == i + 1) {
					Button bottomAddButton = new Button() {
						Content = "+",
						VerticalAlignment = VerticalAlignment.Bottom,
						Margin = new Thickness(10, 5, 10, 0),
						Padding = new Thickness(3)
					};
					
					bottomAddButton.Click += BtnAddRowClick;
					
					bottomAddButton.SetValue(Grid.RowProperty, i);
					this.rowHeightGrid.Children.Add(bottomAddButton);
				}
				
				for (int j = 0; j < cols; j++) {
					StackPanel displayRect = new StackPanel() {
						Margin = new Thickness(5),
						Background = Brushes.LightGray,
						Orientation = Orientation.Vertical
					};
					
					displayRect.AllowDrop = true;
					
					displayRect.Drop += new DragEventHandler(DisplayRectDrop);
					displayRect.DragOver += new DragEventHandler(DisplayRectDragOver);
					
					displayRect.Children.AddRange(BuildItemsForCell(i, j));
					
					displayRect.SetValue(Grid.RowProperty, i);
					displayRect.SetValue(Grid.ColumnProperty, j);
					
					displayRect.ContextMenuOpening += new ContextMenuEventHandler(DisplayRectContextMenuOpening);
					
					this.gridDisplay.Children.Add(displayRect);
				}
			}
			
			this.InvalidateVisual();
		}
        public override void AddUI(Grid grid)
        {
            if (Config != null && Config.ShownAtRunTime)
            {
                grid.RowDefinitions.Add(new RowDefinition());

                var g = new StackPanel { Orientation = Orientation.Vertical, Margin = new Thickness(4, 5, 0, 12) };

                foreach (GPString choice in val.Value)
                {
                    var cb = new CheckBox
                                 {
                                     // default is not checked for all multivalue choices
                                     IsChecked = false,
                                     // tag holds the GPString
                                     Tag = choice
                                 };

                    var item = new TextBlock
                                   {
                                       Text = choice.Value,
                                       TextTrimming = TextTrimming.WordEllipsis,
                                       HorizontalAlignment = HorizontalAlignment.Left,
                                   };
                    ToolTipService.SetToolTip(item, choice.Value);
                    cb.Content = item;

                    cb.Checked += (s, e) =>
                                      {
                                          UpdateValue(cb.IsChecked, cb.Tag);
                                          RaiseCanExecuteChanged();
                                      };
                    cb.Unchecked += (s, e) =>
                                        {
                                            UpdateValue(cb.IsChecked, cb.Tag);
                                            RaiseCanExecuteChanged();
                                        };
                    g.Children.Add(cb);
                }

                // add to the last row (added above)
                g.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                g.SetValue(Grid.ColumnProperty, 0);
                g.SetValue(Grid.ColumnSpanProperty, 2);
                grid.Children.Add(g);
                RaiseCanExecuteChanged();
            }
        }
        public void can_find_parent_node_of_ui_element()
        {
            var panel = new StackPanel();
            var button = new Button();

            panel.Children.Add(button);
            panel.SetValue(
                DefaultRoutedMessageController.NodeProperty,
                new InteractionNode(panel, _controller)
                );

            var parent = _controller.GetParent(button);

            Assert.That(parent, Is.Not.Null);
            Assert.That(parent.UIElement, Is.EqualTo(panel));
        }
        //Constructor
        public EventDimensionSelector(int axis)
        {
            _axis = axis;

            // Create basic DimensionSelectorGrid with four columns
            DimensionSelectorGrid = new Grid { Name = "dimensionSelectorGrid" + axis };
            var col1 = new ColumnDefinition { Width = new GridLength(Column1Width) };
            var col2 = new ColumnDefinition { Width = new GridLength(Column2Width) };
            var col3 = new ColumnDefinition { Width = new GridLength(Column3Width) };
            var col4 = new ColumnDefinition { Width = new GridLength(Column4Width) };
            DimensionSelectorGrid.ColumnDefinitions.Add(col1);
            DimensionSelectorGrid.ColumnDefinitions.Add(col2);
            DimensionSelectorGrid.ColumnDefinitions.Add(col3);
            DimensionSelectorGrid.ColumnDefinitions.Add(col4);

            // Number on the left
            DimensionSelectorGrid.Children.Add(InterfaceHelpers.CreateTextBlock(axis + "", "Title", gridColumn: 0));

            // Create Dimension, Level and Aggregation combo boxes on the middle
            var panelMiddle = new StackPanel();
            panelMiddle.SetValue(Grid.ColumnProperty, 1);
            panelMiddle.HorizontalAlignment = HorizontalAlignment.Left;
            panelMiddle.VerticalAlignment = VerticalAlignment.Top;
            panelMiddle.Children.Add(InterfaceHelpers.CreateLabel("Dimension"));
            _dimensionComboBox = InterfaceHelpers.CreateComboBox("axis" + axis + "_selector", width: ComboBoxWidth);
            panelMiddle.Children.Add(_dimensionComboBox);

            panelMiddle.Children.Add(InterfaceHelpers.CreateLabel("Level", top: LabelTopMargin));
            _dimensionLevelComboBox = InterfaceHelpers.CreateComboBox("level" + axis + "_selector", width: ComboBoxWidth);
            panelMiddle.Children.Add(_dimensionLevelComboBox);

            panelMiddle.Children.Add(InterfaceHelpers.CreateLabel("Aggregation", top: LabelTopMargin));
            _dimensionAggregationComboBox = InterfaceHelpers.CreateComboBox("aggregation" + axis + "_selector", width: ComboBoxWidth);
            panelMiddle.Children.Add(_dimensionAggregationComboBox);

            DimensionSelectorGrid.Children.Add(panelMiddle);

            // Filters on the right
            var panelRight = new StackPanel();
            panelRight.SetValue(Grid.ColumnProperty, 3);
            panelRight.HorizontalAlignment = HorizontalAlignment.Left;
            panelRight.VerticalAlignment = VerticalAlignment.Top;
            panelRight.Children.Add(InterfaceHelpers.CreateLabel("Filter"));
            _dimensionContentSearch = InterfaceHelpers.CreateTextBox("txtSearchAxis" + axis);
            _dimensionContentSearch.Width = SearchBoxWidth;
            panelRight.Children.Add(_dimensionContentSearch);
            // Filterlist
            _dimensionContentFilter = new ListBox
            {
                Name = "filter" + axis + "_selector",
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                Width = FilterListWidth,
                Height = FilterListHeight,
                Style = Application.Current.TryFindResource("ListBox") as Style,
                ItemContainerStyle = Application.Current.TryFindResource("ListBoxItemWithCheckbox") as Style,
                SelectionMode = SelectionMode.Extended
            };
            panelRight.Children.Add(_dimensionContentFilter);

            // Select all / none
            var selectAllNone = new StackPanel { Orientation = Orientation.Horizontal };
            _selectAllButton = InterfaceHelpers.CreateButton("selectAll" + axis, "Select all", "PlainTextButton");
            selectAllNone.Children.Add(_selectAllButton);
            selectAllNone.Children.Add(InterfaceHelpers.CreateLabel("/"));
            _selectNoneButton = InterfaceHelpers.CreateButton("selectNone" + axis, "none", "PlainTextButton");
            selectAllNone.Children.Add(_selectNoneButton);
            panelRight.Children.Add(selectAllNone);

            DimensionSelectorGrid.Children.Add(panelRight);
        }
Пример #21
0
        private void BuildMessageBox(
            string messageBoxText,
            string caption,
            MessageBoxServiceButton button,
            List<string> customLabels)
        {
            var rootVisual = this.FindRootVisual();
            if (null != rootVisual)
            {
                var bgColor = (Color)Application.Current.Resources["PhoneBackgroundColor"];
                var overlayColor = Color.FromArgb(127, bgColor.R, bgColor.G, bgColor.B);
                var fgColor = (Color)Application.Current.Resources["PhoneForegroundColor"];
                var opacityColor = Color.FromArgb(200, bgColor.R, bgColor.G, bgColor.B);
                this._rootElement = new Grid { Background = new SolidColorBrush(overlayColor) };
                this._rootElement.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
                this._rootElement.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
                this._mbsRoot = new Grid
                {
                    Background = new SolidColorBrush(overlayColor),
                    Projection = new PlaneProjection()
                };
                this._mbsRoot.ColumnDefinitions.Add(
                    new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
                this._mbsRoot.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
                this._mbsRoot.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
                this._rootElement.Children.Add(this._mbsRoot);

                // Make sure that our grid spans all rows and columns of it's parent, if the
                // parent is a Grid.
                if (rootVisual is Grid)
                {
                    var parent = (Grid)rootVisual;
                    int columnCount = parent.ColumnDefinitions.Count;
                    if (columnCount > 0)
                    {
                        this._rootElement.SetValue(Grid.ColumnSpanProperty, columnCount);
                    }

                    int rowCount = parent.RowDefinitions.Count;
                    if (rowCount > 0)
                    {
                        this._rootElement.SetValue(Grid.RowSpanProperty, rowCount);
                    }
                }

                Border background = new Border { Background = new SolidColorBrush(fgColor) };
                background.SetValue(Grid.ColumnSpanProperty, 2);
                background.SetValue(Grid.RowSpanProperty, 2);
                this._mbsRoot.Children.Add(background);
                Border opaqueOverlay = new Border { Background = new SolidColorBrush(opacityColor) };
                opaqueOverlay.SetValue(Grid.ColumnSpanProperty, 2);
                opaqueOverlay.SetValue(Grid.RowSpanProperty, 2);
                this._mbsRoot.Children.Add(opaqueOverlay);

                // Add the caption.
                StackPanel container = new StackPanel { Margin = new Thickness(12, 0, 12, 12) };
                container.SetValue(Grid.ColumnSpanProperty, 2);
                TextBlock title = new TextBlock
                {
                    FontFamily = new FontFamily("Segoe WP Semibold"),
                    FontSize = 32,
                    Margin = new Thickness(12),
                    Text = caption,
                    TextWrapping = TextWrapping.Wrap
                };
                title.SetValue(TextOptions.TextHintingModeProperty, TextHintingMode.Animated);
                container.Children.Add(title);

                // Add the message text.
                TextBlock message = new TextBlock
                {
                    FontSize = 24,
                    Margin = new Thickness(12, 0, 12, 0),
                    Text = messageBoxText,
                    TextWrapping = TextWrapping.Wrap
                };
                container.Children.Add(message);
                this._mbsRoot.Children.Add(container);
                rootVisual.Children.Add(this._rootElement);

                // Add the required buttons.
                switch (button)
                {
                    case MessageBoxServiceButton.OK:
                        this.CreateOKButton(
                            null == customLabels ? MessageBoxServiceStrings.OK : customLabels[0],
                            2);
                        container.SetValue(Grid.ColumnSpanProperty, 1);
                        break;
                    case MessageBoxServiceButton.OKCancel:
                        this._mbsRoot.ColumnDefinitions.Add(
                            new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
                        this.CreateOKButton(
                            null == customLabels ? MessageBoxServiceStrings.OK : customLabels[0]);
                        this.CreateCancelButton(
                            null == customLabels ? MessageBoxServiceStrings.Cancel : customLabels[1],
                            1);
                        break;
                    case MessageBoxServiceButton.YesNoCancel:
                        this._mbsRoot.ColumnDefinitions.Add(
                            new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
                        this._mbsRoot.ColumnDefinitions.Add(
                            new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
                        background.SetValue(Grid.ColumnSpanProperty, 3);
                        opaqueOverlay.SetValue(Grid.ColumnSpanProperty, 3);
                        container.SetValue(Grid.ColumnSpanProperty, 3);
                        this.CreateYesButton(
                            null == customLabels ? MessageBoxServiceStrings.Yes : customLabels[0]);
                        this.CreateNoButton(
                            null == customLabels ? MessageBoxServiceStrings.No : customLabels[1],
                            3);
                        this.CreateCancelButton(
                            null == customLabels ? MessageBoxServiceStrings.Cancel : customLabels[2],
                            2);
                        break;
                    case MessageBoxServiceButton.YesNo:
                        this._mbsRoot.ColumnDefinitions.Add(
                            new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
                        this.CreateYesButton(
                            null == customLabels ? MessageBoxServiceStrings.Yes : customLabels[0]);
                        this.CreateNoButton(
                            null == customLabels ? MessageBoxServiceStrings.No : customLabels[1]);
                        break;
                    default:
                        // Not possible to hit this.
                        break;
                }

                // Update and start the storyboard to show the message box.
                foreach (var timeline in this._showStoryboard.Children)
                {
                    Storyboard.SetTarget(timeline, this._mbsRoot);
                }

                // Once the elements are ready, start the storyboard to show them.
                this._mbsRoot.InvokeOnLayoutUpdated(() =>
                {
                    this._showStoryboard.Begin();
                });
            }
        }
        public override void AddUI(Grid grid)
        {
            if (Config != null && Config.ShownAtRunTime)
            {
                #region
                StackPanel panel = new StackPanel()
                {
                    Orientation = System.Windows.Controls.Orientation.Horizontal,
                    HorizontalAlignment = System.Windows.HorizontalAlignment.Left
                };
                TextBox tb = new TextBox() { Margin = new Thickness(2), Width = 50 };
                tb.SetValue(Grid.ColumnProperty, 0);
                tb.SetValue(ToolTipService.ToolTipProperty, Config.ToolTip);
               if (value != null)
                    tb.Text = value.Distance.ToString();
               tb.TextChanged += (s, e) =>
               {
                   double val = double.NaN;
                   if (double.TryParse(tb.Text, System.Globalization.NumberStyles.Any, CultureHelper.GetCurrentCulture(), out val))
                   {
                       if (value == null)
                           Value = new GPLinearUnit(Config.Name, esriUnits.esriUnknownUnits, val);
                       else
                           value.Distance = val;
                   }
                   else
                   {
                       if (value == null)
                           Value = new GPLinearUnit(Config.Name, esriUnits.esriUnknownUnits, double.NaN);
                       else
                           value.Distance = double.NaN;
                   }
                   RaiseCanExecuteChanged();
               };
               panel.Children.Add(tb);

               ComboBox cb = new ComboBox()
               {
                   HorizontalAlignment = System.Windows.HorizontalAlignment.Left,
                   Width = 125,
                   Height = 24,
                   Margin = new Thickness(2),
                   Foreground = new SolidColorBrush(Colors.Black)
               };
                cb.SetValue(Grid.ColumnProperty, 1);
                cb.Items.Add(new TextBlock() { Text = Strings.Unknown, Tag = esriUnits.esriUnknownUnits});
                cb.Items.Add(new TextBlock() { Text = Strings.Inches, Tag = esriUnits.esriInches });
                cb.Items.Add(new TextBlock() { Text = Strings.Points, Tag = esriUnits.esriPoints });
                cb.Items.Add(new TextBlock() { Text = Strings.Feet, Tag = esriUnits.esriFeet });
                cb.Items.Add(new TextBlock() { Text = Strings.Yards, Tag = esriUnits.esriYards });
                cb.Items.Add(new TextBlock() { Text = Strings.Miles, Tag = esriUnits.esriMiles });
                cb.Items.Add(new TextBlock() { Text = Strings.NauticalMiles, Tag = esriUnits.esriNauticalMiles });
                cb.Items.Add(new TextBlock() { Text = Strings.Millimeters, Tag = esriUnits.esriMillimeters });
                cb.Items.Add(new TextBlock() { Text = Strings.Centimeters, Tag = esriUnits.esriCentimeters });
                cb.Items.Add(new TextBlock() { Text = Strings.Meters, Tag = esriUnits.esriMeters });
                cb.Items.Add(new TextBlock() { Text = Strings.Kilometers, Tag = esriUnits.esriKilometers });
                cb.Items.Add(new TextBlock() { Text = Strings.DecimalDegrees, Tag = esriUnits.esriDecimalDegrees });
                cb.Items.Add(new TextBlock() { Text = Strings.Decimeters, Tag = esriUnits.esriDecimeters });

                TextBlock item;                
                for (int i = 0; i < cb.Items.Count; i++)
                {
                    item = cb.Items[i] as TextBlock;
                    if (((esriUnits)item.Tag) == value.Unit)
                    {
                        cb.SelectedIndex = i;
                        cb.SelectedItem = item;
                    }
                }
                cb.SelectionChanged += (a, b) =>
                    {
                        value.Unit = (esriUnits)((cb.SelectedItem as TextBlock).Tag);
                        RaiseCanExecuteChanged();
                    };
                panel.Children.Add(cb);
                panel.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                panel.SetValue(Grid.ColumnProperty, 1);
                grid.Children.Add(panel);
                #endregion
                RaiseCanExecuteChanged();
            }
        }
Пример #23
0
        public void NodeDetailDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (m_NodeDetailAttributes == null)
                return;

            var grid = sender as Grid;

            var columns = 4;
            var rows = (int)Math.Ceiling((double)m_NodeDetailAttributes.Length / (double)columns);

            for (var i = 0; i < columns; i++)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition());
            }

            for (var i = 0; i < rows; i++)
            {
                grid.RowDefinitions.Add(new RowDefinition());
            }

            var k = 0;

            for (var i = 0; i < rows; i++)
            {
                for (var j = 0; j < columns; j++)
                {
                    var att = m_NodeDetailAttributes[k++];

                    var nameValuePanel = new StackPanel();
                    nameValuePanel.Orientation = Orientation.Horizontal;

                    var label = new TextBlock();
                    label.Style = App.Current.Resources["GlobalInfoLabel"] as Style;
                    label.Text = att.Name + ":";
                    nameValuePanel.Children.Add(label);

                    var value = new TextBlock();
                    value.Style = App.Current.Resources["GlobalInfoValue"] as Style;
                    value.SetBinding(TextBlock.TextProperty, new Binding(GetColumnValueBindingName("Values", att.Key))
                    {
                        StringFormat = string.IsNullOrEmpty(att.Format) ? "{0}" : att.Format
                    });
                    nameValuePanel.Children.Add(value);

                    nameValuePanel.SetValue(Grid.ColumnProperty, j);
                    nameValuePanel.SetValue(Grid.RowProperty, i);
                    grid.Children.Add(nameValuePanel);

                    if (k >= m_NodeDetailAttributes.Length)
                        break;
                }
            }
        }
        /// <summary>
        /// Creates for each dimension a column with textboxes(dimension, level) where the metadata can be modified
        /// </summary>
        /// <author>Jannik Arndt, Bernhard Bruns</author>
        private void LoadDimensionMetaData()
        {
            DimensionGrid.Children.Clear();
            DimensionGrid.ColumnDefinitions.Clear();

            foreach (string registeredName in _registeredNames)
                DimensionGrid.UnregisterName(registeredName);

            _registeredNames.Clear();

            // Load the columnnames of the event table into the combobox to let the user decide which one to use as a classifier
            ClassifierComboBox.ItemsSource = DBWorker.MetaData.ListOfEventsTableColumnNames;

            if (DBWorker.MetaData.ListOfEventsTableColumnNames.Contains(DBWorker.MetaData.EventClassifier))
                ClassifierComboBox.SelectedItem = DBWorker.MetaData.EventClassifier;
            else if (DBWorker.MetaData.ListOfEventsTableColumnNames.Count > 0)
            {
                ClassifierComboBox.SelectedIndex = 0;
            }

            int dimensionNumber = 0;
            foreach (Dimension dimension in DBWorker.MetaData.ListOfFactDimensions)
            {
                DimensionGrid.ColumnDefinitions.Add(new ColumnDefinition());

                if (!dimension.IsEmptyDimension && dimension.Name != "--no selection--")
                {
                    StackPanel dimensionPanel = new StackPanel();
                    dimensionPanel.SetValue(Grid.ColumnProperty, dimensionNumber);
                    dimensionPanel.Width = 150;

                    dimensionPanel.Children.Add(InterfaceHelpers.CreateTextBlock("DIMENSION " + (dimensionNumber + 1), "Emphasis", bottom: 8));
                    dimensionPanel.Children.Add(InterfaceHelpers.CreateTextBlock("Original Name: \n" + dimension.Name, bottom: 8));
                    dimensionPanel.Children.Add(InterfaceHelpers.CreateTextBlock("New Name:", bottom: 8));

                    TextBox dimensionNumberTextBox = InterfaceHelpers.CreateTextBox("Dimension" + (dimensionNumber + 1) + "newName", dimension.Dimensionname, bottom: 8);
                    dimensionNumberTextBox.GotKeyboardFocus += SelectTextInTextbox;

                    DimensionGrid.RegisterName(dimensionNumberTextBox.Name, dimensionNumberTextBox);
                    _registeredNames.Add(dimensionNumberTextBox.Name);
                    dimensionPanel.Children.Add(dimensionNumberTextBox);

                    dimensionPanel.Children.Add(InterfaceHelpers.CreateTextBlock("LEVELS", "Emphasis", top: 20, bottom: 8));

                    int j = 0;
                    foreach (Dimension cDim in dimension.GetLevel())
                    {
                        if (j >= 0)
                        {
                            dimensionPanel.Children.Add(InterfaceHelpers.CreateTextBlock(cDim.ToTable, bottom: 8));

                            TextBox txtLevel = InterfaceHelpers.CreateTextBox("level" + (dimensionNumber + 1) + "_" + j + "newName", cDim.Level, bottom: 15);
                            txtLevel.GotKeyboardFocus += SelectTextInTextbox;

                            DimensionGrid.RegisterName(txtLevel.Name, txtLevel);
                            _registeredNames.Add(txtLevel.Name);
                            dimensionPanel.Children.Add(txtLevel);
                        }
                        j++;
                    }

                    DimensionGrid.Children.Add(dimensionPanel);
                    dimensionNumber++;
                }
            }

            if (DBConnectionHelpers.DefaultEventClassifierIsSelected)
            {
                ModernDialog.ShowMessage("Auto selected " + ClassifierComboBox.SelectedItem + " as classifier.", "Metadata", MessageBoxButton.OK);
                DBConnectionHelpers.DefaultEventClassifierIsSelected = false;
            }
        }
Пример #25
0
        private void GetMonthHighCompleted(object sender, GetHighscoresCompletedEventArgs e)
        {
            if (e.Result != null)
            {
                var grid = (Grid) _dialog.DialogContents.Content;
                var panel = new StackPanel();
                panel.SetValue(Grid.RowProperty, 0);
                panel.SetValue(Grid.ColumnProperty, 1);
                grid.Children.Add(panel);

                var header = new TextBlock
                                 {
                                     Style = Styles.StrongText,
                                     Text = String.Format(Strings.HighScoreMonth, DateTime.Today.ToString("MMMM")),
                                     Margin = new Thickness(0, 0, 0, 5)
                                 };
                panel.Children.Add(header);

                int place = 1;
                foreach (DataItem score in e.Result)
                {
                    AddHighScore(panel, place, score.Name, score.Value);
                    place++;
                }
            }
            _dialog.LoadingCompleted();
        }
Пример #26
0
        /// <summary>
        /// Create AxisY elements for circular chart
        /// </summary>
        /// <param name="height"></param>
        /// <param name="point"></param>
        /// <param name="minAngle"></param>
        /// <param name="index"></param>
        /// <param name="center"></param>
        /// <param name="isAxisLabelsEnabled"></param>
        private void CreateAxisYElements4RadarChart(Double height, Point point, Double minAngle, Double index, Point center, Boolean isAxisLabelsEnabled)
        {
            AxisElementsContainer = new StackPanel() { Background = InternalBackground };
            AxisElementsContainer.Orientation = Orientation.Horizontal;

            ApplyAxisProperties4CircularChart();

            CreateAxisLine(0, height, (Double)LineThickness / 2, (Double)LineThickness / 2, (Double)LineThickness, height);

            RotateTransform transform = null;

            if (isAxisLabelsEnabled)
            {
                AxisLabels.CreateVisualObject();

                if (AxisLabels.Visual != null)
                    AxisElementsContainer.Children.Add(AxisLabels.Visual);
            }
            else
            {
                transform = new RotateTransform();
                transform.Angle = minAngle * index;
            }

            Double ticksWidth = 0;

            List<Ticks> ticks = Ticks.Reverse().ToList();

            foreach (Ticks tick in ticks)
            {
                tick.SetParms(PlacementTypes.Left, Double.NaN, height);

                tick.CreateVisualObject();

                if (tick.Visual != null)
                {
                    AxisElementsContainer.Children.Add(tick.Visual);
                    ticksWidth += tick.Visual.Width;
                }
            }

            if (AxisLine != null)
                AxisElementsContainer.Children.Add(AxisLine);

            Double axisLabelsWidth = 0;
            if (isAxisLabelsEnabled)
            {
                if (AxisLabels.Visual != null)
                {
                    if(!Double.IsNaN(AxisLabels.Visual.Width))
                        axisLabelsWidth = AxisLabels.Visual.Width;
                }
            }

            AxisElementsContainer.SetValue(Canvas.LeftProperty, point.X - axisLabelsWidth - ticksWidth);
            AxisElementsContainer.SetValue(Canvas.TopProperty, point.Y);

            if (!isAxisLabelsEnabled)
            {
                if (transform != null)
                {
                    AxisElementsContainer.RenderTransformOrigin = new Point(0.75, 0);
                    AxisElementsContainer.RenderTransform = transform;
                }
            }

            CircularAxisVisual.Children.Add(AxisElementsContainer);
        }
        public override void AddConfigUI(System.Windows.Controls.Grid grid)
        {
            base.AddConfigUI(grid);
            #region Layer name
            grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            TextBlock layerName = new TextBlock()
            {
                Text = Resources.Strings.LabelLayerName,
                Margin = new Thickness(2),
                VerticalAlignment = System.Windows.VerticalAlignment.Center
            };
            layerName.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
            grid.Children.Add(layerName);
            TextBox labelTextBox = new TextBox()
            {
                Text = LayerName == null ? string.Empty : LayerName,
                Margin = new Thickness(2),
                HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
            };
            labelTextBox.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
            labelTextBox.SetValue(Grid.ColumnProperty, 1);
            grid.Children.Add(labelTextBox);
            labelTextBox.TextChanged += (s, e) =>
            {
                LayerName = labelTextBox.Text;
            };
            #endregion
            #region Renderer
            grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            TextBlock label2 = new TextBlock()
            {
                Text = Resources.Strings.LabelRenderer,
                Margin = new Thickness(2),
                VerticalAlignment = System.Windows.VerticalAlignment.Center
            };
            label2.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
            grid.Children.Add(label2);
            Button rendererButton = null;
            if (GeometryType == Core.GeometryType.Unknown)
            {
                TextBlock tb = new TextBlock() { Text = Resources.Strings.NotAvailable, VerticalAlignment = VerticalAlignment.Center };
                ToolTipService.SetToolTip(tb, Resources.Strings.GeometryTypeIsNotKnown);
                tb.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                tb.SetValue(Grid.ColumnProperty, 1);
                grid.Children.Add(tb);
            }
            else
            {
                rendererButton = new Button()
                {
                    Content = new Image()
                               {
                                   Source = new BitmapImage(new Uri("/ESRI.ArcGIS.Mapping.GP;component/Images/ColorScheme16.png", UriKind.Relative)),
                                   Stretch = Stretch.None,
                                   VerticalAlignment = System.Windows.VerticalAlignment.Center,
                                   HorizontalAlignment = System.Windows.HorizontalAlignment.Center
                               },
                    Width = 22,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Style = Application.Current.Resources["SimpleButtonStyle"] as Style,
                    IsEnabled = (Mode == InputMode.SketchLayer),
                };
                ToolTipService.SetToolTip(rendererButton, Resources.Strings.ConfigureRenderer);
                rendererButton.Click += rendererButton_Click;
                rendererButton.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                rendererButton.SetValue(Grid.ColumnProperty, 1);
                grid.Children.Add(rendererButton);
            }
            #endregion
            #region Popup Config
            grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            label2 = new TextBlock()
            {
                Text = Resources.Strings.LabelPopUps,
                Margin = new Thickness(2),
                VerticalAlignment = System.Windows.VerticalAlignment.Center
            };
            label2.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
            grid.Children.Add(label2);
            Button popupButton = null;
            if (Layer == null)
            {
                TextBlock tb = new TextBlock() { Text = Resources.Strings.NotAvailable, VerticalAlignment = VerticalAlignment.Center };
                ToolTipService.SetToolTip(tb, Resources.Strings.FieldInformationIsNotKnown);
                tb.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                tb.SetValue(Grid.ColumnProperty, 1);
                grid.Children.Add(tb);
            }
            else
            {
                popupButton = new Button()
                {
                    Content = new Image()
                    {
                        Source = new BitmapImage(new Uri("/ESRI.ArcGIS.Mapping.GP;component/Images/Show_Popup16.png", UriKind.Relative)),
                        Stretch = Stretch.None,
                        VerticalAlignment = System.Windows.VerticalAlignment.Center,
                        HorizontalAlignment = System.Windows.HorizontalAlignment.Center
                    },
                    Width = 22,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Style = Application.Current.Resources["SimpleButtonStyle"] as Style,
                    IsEnabled = (Mode == InputMode.SketchLayer),
                };
                ToolTipService.SetToolTip(popupButton, Resources.Strings.ConfigurePopupFieldAliasesAndVisibility);
                popupButton.Click += popupButton_Click;
                popupButton.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                popupButton.SetValue(Grid.ColumnProperty, 1);
                grid.Children.Add(popupButton);
            }
            #endregion

            #region Transparency
            grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            label2 = new TextBlock()
            {
                Text = Resources.Strings.LabelTransparency,
                Margin = new Thickness(2),
                VerticalAlignment = System.Windows.VerticalAlignment.Top
            };
            label2.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
            grid.Children.Add(label2);

            ContentControl slider = new ContentControl()
            {
                DataContext = this,
                IsEnabled = (Mode == InputMode.SketchLayer),
                Style = ResourceUtility.LoadEmbeddedStyle("Themes/HorizontalTransparencySlider.xaml", "TransparencySliderStyle")
            };
            //Slider slider = new Slider()
            //{
            //    DataContext = this,
            //    IsEnabled = (Mode == InputMode.SketchLayer),
            //    Orientation = Orientation.Horizontal,
            //    Width = 145,
            //    Minimum = 0,
            //    Maximum = 1
            //};
            //slider.SetBinding(Slider.ValueProperty,
            //    new System.Windows.Data.Binding("Opacity") { Mode = System.Windows.Data.BindingMode.TwoWay });
            slider.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
            slider.SetValue(Grid.ColumnProperty, 1);
            grid.Children.Add(slider);
            #endregion

            if (Input)
            {
                #region Input Mode
                grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
                TextBlock label = new TextBlock()
                {
                    Text = Resources.Strings.LabelInputFeatures,
                    Margin = new Thickness(2),
                    VerticalAlignment = System.Windows.VerticalAlignment.Center
                };
                label.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                grid.Children.Add(label);

                grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
                StackPanel panel = new StackPanel()
                {
                    Orientation = System.Windows.Controls.Orientation.Vertical,
                    Margin = new Thickness(15, 0, 0, 0),
                };
                panel.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                panel.SetValue(Grid.ColumnSpanProperty, 2);
                RadioButton interactive = new RadioButton()
                {
                    Content = Resources.Strings.Interactively,
                    IsChecked = (Mode == InputMode.SketchLayer),
                    Margin = new Thickness(2),
                    Foreground = Application.Current.Resources["DesignHostBackgroundTextBrush"] as Brush
                };
                panel.Children.Add(interactive);
                RadioButton selection = new RadioButton()
                {
                    Content = Resources.Strings.BySelectingLayerFromMap,
                    IsChecked = (Mode == InputMode.SelectExistingLayer),
                    Margin = new Thickness(2),
                    Foreground = Application.Current.Resources["DesignHostBackgroundTextBrush"] as Brush
                };
                panel.Children.Add(selection);
                RadioButton fromExtent = null;
                if (GeometryType == Core.GeometryType.Polygon)
                {
                    fromExtent = new RadioButton()
                    {
                        Content = Resources.Strings.FromMapExtent,
                        IsChecked = (Mode == InputMode.CurrentExtent),
                        Margin = new Thickness(2),
                        Foreground = Application.Current.Resources["DesignHostBackgroundTextBrush"] as Brush
                    };
                    panel.Children.Add(fromExtent);

                }
                interactive.Checked += (a, b) =>
                {
                    Mode = InputMode.SketchLayer;
                    selection.IsChecked = false;
                    if (fromExtent != null)
                        fromExtent.IsChecked = false;
                    if (popupButton != null)
                        popupButton.IsEnabled = true;
                    if (rendererButton != null)
                        rendererButton.IsEnabled = true;
                    //if (slider != null)
                    //    slider.IsEnabled = true;
                };
                selection.Checked += (a, b) =>
                 {
                     Mode = InputMode.SelectExistingLayer;
                     interactive.IsChecked = false;
                     if (fromExtent != null)
                         fromExtent.IsChecked = false;
                     if (popupButton != null)
                         popupButton.IsEnabled = false;
                     if (rendererButton != null)
                         rendererButton.IsEnabled = false;
                     //if (slider != null)
                     //    slider.IsEnabled = false;
                 };
                if (fromExtent != null)
                {
                    fromExtent.Checked += (a, b) =>
                     {
                         Mode = InputMode.CurrentExtent;
                         interactive.IsChecked = false;
                         selection.IsChecked = false;
                         if (popupButton != null)
                             popupButton.IsEnabled = false;
                         if (rendererButton != null)
                             rendererButton.IsEnabled = false;
                         //if (slider != null)
                         //    slider.IsEnabled = false;
                     };
                }
                grid.Children.Add(panel);
                #endregion
            }
        }
Пример #28
0
        protected void RenderPost(MitbbsPostBase post)
        {
            // Header
            //
            Border headerLine = new Border();
            headerLine.BorderThickness = new Thickness(1);
            headerLine.Margin = new Thickness(0, 10, 0, 0);
            //headerLine.BorderBrush = (Brush)App.Current.Resources["PhoneAccentBrush"];
            headerLine.BorderBrush = new LinearGradientBrush()
            {
                StartPoint = new Point(0, 0),
                EndPoint = new Point(1, 0),
                GradientStops = new GradientStopCollection()
                    {
                        new GradientStop()
                        {
                            Color = ((SolidColorBrush)App.Current.Resources["PhoneAccentBrush"]).Color,
                            Offset = 0
                        },

                        new GradientStop()
                        {
                            Color = ((SolidColorBrush)App.Current.Resources["PhoneSubtleBrush"]).Color,
                            Offset = 0.8
                        },
                        new GradientStop()
                        {
                            Color = ((SolidColorBrush)App.Current.Resources["PhoneBackgroundBrush"]).Color,
                            Offset = 1
                        },
                    }
            };

            //headerLine.BorderBrush = (Brush)App.Current.Resources["PhoneSubtleBrush"];
            //headerLine.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 112, 146, 190));
            headerLine.Height = .5;

            _firstPostControls.Add(headerLine);
            _topicBodyPanel.Children.Add(headerLine);

            StackPanel headerPanel = new StackPanel();
            headerPanel.Orientation = System.Windows.Controls.Orientation.Vertical;

            Grid headerPanel2 = new Grid();
            ColumnDefinition column1 = new ColumnDefinition();
            column1.Width = new GridLength(1, GridUnitType.Star);
            ColumnDefinition column2 = new ColumnDefinition();
            column2.Width = new GridLength(1, GridUnitType.Auto);
            headerPanel2.ColumnDefinitions.Add(column1);
            headerPanel2.ColumnDefinitions.Add(column2);

            Grid expandButtonPanel = new Grid();
            expandButtonPanel.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;

            StackPanel headerPanel3 = new StackPanel();
            headerPanel3.Orientation = System.Windows.Controls.Orientation.Vertical;
            headerPanel3.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;

            Button expandButton = new Button();
            ImageBrush expandButtonImage = new ImageBrush();
            expandButtonImage.ImageSource = new BitmapImage(new Uri("/MitbbsReader;component/Images/overflowdots.png", UriKind.Relative));
            expandButtonImage.Stretch = Stretch.None;
            expandButton.Style = (Style)Application.Current.Resources["ImageButton"];
            expandButton.Content = expandButtonImage;
            expandButton.Padding = new Thickness(0);
            expandButton.BorderThickness = new Thickness(0);
            expandButton.Margin = new Thickness(0);
            expandButton.Width = 93;
            expandButton.Height = 54;

            GestureListener gl = GestureService.GetGestureListener(expandButton);
            gl.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(GeneralButton_Tapped);

            expandButton.Click += ExpandButton_Click;

            headerPanel3.SetValue(Grid.ColumnProperty, 0);
            expandButtonPanel.SetValue(Grid.ColumnProperty, 1);
            headerPanel2.Children.Add(headerPanel3);
            headerPanel2.Children.Add(expandButtonPanel);
            expandButtonPanel.Children.Add(expandButton);

            headerPanel.Children.Add(headerPanel2);

            TextBlock authorText = new TextBlock();
            authorText.Text = "作者: " + post.Author;
            authorText.FontWeight = FontWeights.ExtraBold;
            //authorText.Style = (Style)App.Current.Resources["PhoneTextAccentStyle"];
            authorText.FontSize = (double)App.Current.Resources["MitbbsFontSizeNormal"];
            authorText.Margin = new Thickness(0);
            authorText.TextWrapping = TextWrapping.Wrap;

            TextBlock sourceText = new TextBlock();
            sourceText.Text = "时间: " + post.IssueDate;
            sourceText.FontWeight = FontWeights.ExtraBold;
            //sourceText.Style = (Style)App.Current.Resources["PhoneTextAccentStyle"];
            sourceText.FontSize = (double)App.Current.Resources["MitbbsFontSizeNormal"];
            sourceText.Margin = new Thickness(0);
            sourceText.TextWrapping = TextWrapping.Wrap;

            headerPanel3.Children.Add(authorText);
            headerPanel3.Children.Add(sourceText);

            //Header buttons
            StackPanel buttonPanel = new StackPanel();
            buttonPanel.Orientation = System.Windows.Controls.Orientation.Horizontal;
            buttonPanel.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;

            Border buttonBorder = new Border();
            buttonBorder.BorderBrush = (Brush)App.Current.Resources["PhoneAccentBrush"];
            buttonBorder.BorderThickness = new Thickness(2);
            buttonBorder.CornerRadius = new CornerRadius(3);
            buttonBorder.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            buttonBorder.Visibility = Visibility.Collapsed;
            buttonBorder.Child = buttonPanel;

            //expandButton.DataContext = buttonBorder;
            expandButton.DataContext = post;

            int buttonSize = 72;

            //int buttonCount = 0;

            //if (!_offline && post.ReplyPostUrl != null)
            //{
            //    Button replyButton = new Button();
            //    ImageBrush replyButtonImage = new ImageBrush();
            //    replyButtonImage.ImageSource = new BitmapImage(new Uri("/MitbbsReader;component/Images/reply_roundbutton.png", UriKind.Relative));
            //    replyButtonImage.Stretch = Stretch.None;
            //    replyButton.Style = (Style)Application.Current.Resources["ImageButton"];
            //    replyButton.Content = replyButtonImage;
            //    replyButton.Padding = new Thickness(0);
            //    replyButton.BorderThickness = new Thickness(0);
            //    replyButton.Margin = new Thickness(0);
            //    replyButton.Width = buttonSize;
            //    replyButton.Height = buttonSize;

            //    GestureListener gl2 = GestureService.GetGestureListener(replyButton);
            //    gl2.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(GeneralButton_Tapped);

            //    replyButton.Click += ReplyButton_Click;
            //    replyButton.DataContext = post;
            //    buttonPanel.Children.Add(replyButton);
            //    buttonCount++;
            //}

            //if (!_offline && _showQuickReply && (post.ReplyPostUrl != null))
            //{
            //    Button quickReplyButton = new Button();
            //    ImageBrush quickReplyButtonImage = new ImageBrush();
            //    quickReplyButtonImage.ImageSource = new BitmapImage(new Uri("/MitbbsReader;component/Images/quicksend_roundbutton.png", UriKind.Relative));
            //    quickReplyButtonImage.Stretch = Stretch.None;
            //    quickReplyButton.Style = (Style)Application.Current.Resources["ImageButton"];
            //    quickReplyButton.Content = quickReplyButtonImage;
            //    quickReplyButton.Padding = new Thickness(0);
            //    quickReplyButton.BorderThickness = new Thickness(0);
            //    quickReplyButton.Margin = new Thickness(0);
            //    quickReplyButton.Width = buttonSize;
            //    quickReplyButton.Height = buttonSize;

            //    GestureListener gl2 = GestureService.GetGestureListener(quickReplyButton);
            //    gl2.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(GeneralButton_Tapped);

            //    quickReplyButton.Click += QuickReplyButton_Click;
            //    quickReplyButton.DataContext = post;
            //    buttonPanel.Children.Add(quickReplyButton);
            //    buttonCount++;
            //}

            //if (!_offline && post.ForwardUrl != null)
            //{
            //    Button forwardButton = new Button();
            //    ImageBrush forwardButtonImage = new ImageBrush();
            //    forwardButtonImage.ImageSource = new BitmapImage(new Uri("/MitbbsReader;component/Images/Clipboard-file_roundbutton.png", UriKind.Relative));
            //    forwardButtonImage.Stretch = Stretch.None;
            //    forwardButton.Style = (Style)Application.Current.Resources["ImageButton"];
            //    forwardButton.Content = forwardButtonImage;
            //    forwardButton.Padding = new Thickness(0);
            //    forwardButton.BorderThickness = new Thickness(0);
            //    forwardButton.Margin = new Thickness(0);
            //    forwardButton.Width = buttonSize;
            //    forwardButton.Height = buttonSize;

            //    GestureListener gl2 = GestureService.GetGestureListener(forwardButton);
            //    gl2.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(GeneralButton_Tapped);

            //    forwardButton.Click += ForwardButton_Click;
            //    forwardButton.DataContext = post;
            //    buttonPanel.Children.Add(forwardButton);
            //    buttonCount++;
            //}

            //if (!_offline && _showReplyToUser && (post.AuthorId != null) && !(App.WebSession.IsLoggedIn && App.WebSession.Username.ToLower() == post.AuthorId.ToLower()))
            //{
            //    Button replyUserButton = new Button();
            //    ImageBrush replyUserButtonImage = new ImageBrush();
            //    replyUserButtonImage.ImageSource = new BitmapImage(new Uri("/MitbbsReader;component/Images/contact_roundbutton.png", UriKind.Relative));
            //    replyUserButtonImage.Stretch = Stretch.None;
            //    replyUserButton.Style = (Style)Application.Current.Resources["ImageButton"];
            //    replyUserButton.Content = replyUserButtonImage;
            //    replyUserButton.Padding = new Thickness(0);
            //    replyUserButton.BorderThickness = new Thickness(0);
            //    replyUserButton.Margin = new Thickness(0);
            //    replyUserButton.Width = buttonSize;
            //    replyUserButton.Height = buttonSize;

            //    GestureListener gl2 = GestureService.GetGestureListener(replyUserButton);
            //    gl2.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(GeneralButton_Tapped);

            //    replyUserButton.Click += ReplyUserButton_Click;
            //    replyUserButton.DataContext = post;
            //    buttonPanel.Children.Add(replyUserButton);
            //    buttonCount++;
            //}

            //if (!_offline && App.WebSession.IsLoggedIn && App.WebSession.Username.ToLower() == post.AuthorId.ToLower())
            //{
            //    if (post.DeletePostUrl != null)
            //    {
            //        Button deleteButton = new Button();
            //        ImageBrush deleteButtonImage = new ImageBrush();
            //        deleteButtonImage.ImageSource = new BitmapImage(new Uri("/MitbbsReader;component/Images/trash_roundbutton.png", UriKind.Relative));
            //        deleteButtonImage.Stretch = Stretch.None;
            //        deleteButton.Style = (Style)Application.Current.Resources["ImageButton"];
            //        deleteButton.Content = deleteButtonImage;
            //        deleteButton.Padding = new Thickness(0);
            //        deleteButton.BorderThickness = new Thickness(0);
            //        deleteButton.Margin = new Thickness(0);
            //        deleteButton.Width = buttonSize;
            //        deleteButton.Height = buttonSize;

            //        GestureListener gl2 = GestureService.GetGestureListener(deleteButton);
            //        gl2.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(GeneralButton_Tapped);

            //        deleteButton.Click += DeleteButton_Click;
            //        deleteButton.DataContext = post;
            //        buttonPanel.Children.Add(deleteButton);
            //        buttonCount++;
            //    }
            //}

            //if (!_offline && App.WebSession.IsLoggedIn && App.WebSession.Username.ToLower() == post.AuthorId.ToLower())
            //{
            //    if (post.ModifyPostUrl != null)
            //    {
            //        Button modifyButton = new Button();
            //        ImageBrush modifyButtonImage = new ImageBrush();
            //        modifyButtonImage.ImageSource = new BitmapImage(new Uri("/MitbbsReader;component/Images/edit_roundbutton.png", UriKind.Relative));
            //        modifyButtonImage.Stretch = Stretch.None;
            //        modifyButton.Style = (Style)Application.Current.Resources["ImageButton"];
            //        modifyButton.Content = modifyButtonImage;
            //        modifyButton.Padding = new Thickness(0);
            //        modifyButton.BorderThickness = new Thickness(0);
            //        modifyButton.Margin = new Thickness(0);
            //        modifyButton.Width = buttonSize;
            //        modifyButton.Height = buttonSize;

            //        GestureListener gl2 = GestureService.GetGestureListener(modifyButton);
            //        gl2.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(GeneralButton_Tapped);

            //        modifyButton.Click += ModifyButton_Click;
            //        modifyButton.DataContext = post;
            //        buttonPanel.Children.Add(modifyButton);
            //        buttonCount++;
            //    }
            //}

            //{
            //    Button shareButton = new Button();
            //    ImageBrush shareButtonImage = new ImageBrush();
            //    shareButtonImage.ImageSource = new BitmapImage(new Uri("/MitbbsReader;component/Images/share_roundbutton.png", UriKind.Relative));
            //    shareButtonImage.Stretch = Stretch.None;
            //    shareButton.Style = (Style)Application.Current.Resources["ImageButton"];
            //    shareButton.Content = shareButtonImage;
            //    shareButton.Padding = new Thickness(0);
            //    shareButton.BorderThickness = new Thickness(0);
            //    shareButton.Margin = new Thickness(0);
            //    shareButton.Width = buttonSize;
            //    shareButton.Height = buttonSize;

            //    GestureListener gl2 = GestureService.GetGestureListener(shareButton);
            //    gl2.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(GeneralButton_Tapped);

            //    shareButton.Click += ShareButton_Click;
            //    shareButton.DataContext = post;
            //    buttonPanel.Children.Add(shareButton);
            //    buttonCount++;
            //}

            //if (buttonCount > 0)
            //{
            //    buttonBorder.Width = buttonCount * buttonSize;
            //    headerPanel.Children.Add(buttonBorder);
            //}
            //else
            //{
            //    expandButtonPanel.Visibility = Visibility.Collapsed;
            //}

            _topicBodyPanel.Children.Add(headerPanel);

            // Body
            //
            bool firstContent = true;
            for (int index = 0; index < post.Contents.Count; index++)
            {
                ContentBlock content = post.Contents[index];
                bool isSignature = (post.SignatureStart >= 0) && (index > post.SignatureStart);

                if (content is ImageBlock)
                {
                    String imageUrl = (content as ImageBlock).ImageUrl;

                    try
                    {
                        _imageLoader.LoadImage(
                                        imageUrl,
                                        HtmlUtilities.GetAbsoluteUrl(imageUrl, "/")
                                        );
                    }
                    catch (Exception e)
                    {
                        Debug.WriteLine(e.ToString());
                    }
                }
                else if (content is LinkBlock)
                {
                    String url = (content as LinkBlock).Url;
                    if (MitbbsLinkConverter.IsMitbbsFullTopicLink(url))
                    {
                        Button articleButton = new Button();
                        ImageBrush articleButtonImage = new ImageBrush();
                        articleButtonImage.ImageSource = new BitmapImage(new Uri("/MitbbsReader;component/Images/right_roundbutton.png", UriKind.Relative));
                        articleButtonImage.Stretch = Stretch.Uniform;
                        articleButton.Style = (Style)Application.Current.Resources["ImageButton"];
                        articleButton.Content = articleButtonImage;
                        articleButton.Padding = new Thickness(0);
                        articleButton.BorderThickness = new Thickness(0);
                        articleButton.Margin = new Thickness(0);

                        GestureListener gl2 = GestureService.GetGestureListener(articleButton);
                        gl2.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(GeneralButton_Tapped);

                        articleButton.Click += ArticleButton_Click;
                        articleButton.DataContext = content;

                        HyperlinkButton link = new HyperlinkButton();
                        link.SetValue(TiltEffect.IsTiltEnabledProperty, true);
                        link.Click += GeneralLink_Click;
                        link.DataContext = content;
                        link.Content = "打开未名空间文章";
                        link.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                        link.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left;

                        Border articlePanelBorder = new Border();
                        articlePanelBorder.BorderBrush = (Brush)App.Current.Resources["PhoneForegroundBrush"];
                        articlePanelBorder.BorderThickness = new Thickness(2);

                        if (isSignature)
                        {
                            articleButton.Width = buttonSize * 2 / 3;
                            articleButton.Height = buttonSize * 2 / 3;
                            articleButton.Foreground = (Brush)App.Current.Resources["PhoneSubtleBrush"];
                            link.FontSize = (double)App.Current.Resources["PhoneFontSizeSmall"];
                            link.Foreground = (Brush)App.Current.Resources["PhoneSubtleBrush"];
                            articlePanelBorder.BorderBrush = (Brush)App.Current.Resources["PhoneSubtleBrush"];
                            articlePanelBorder.BorderThickness = new Thickness(1);
                            articlePanelBorder.Width = 300;
                            articlePanelBorder.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                        }
                        else
                        {
                            articleButton.Width = buttonSize;
                            articleButton.Height = buttonSize;
                            link.FontSize = (double)App.Current.Resources["MitbbsFontSizeText"];
                            articlePanelBorder.BorderBrush = (Brush)App.Current.Resources["PhoneForegroundBrush"];
                            articlePanelBorder.BorderThickness = new Thickness(2);
                            articlePanelBorder.Width = 350;
                        }

                        StackPanel articlePanel = new StackPanel() { Orientation = System.Windows.Controls.Orientation.Horizontal };

                        articlePanelBorder.Child = articlePanel;
                        articlePanel.Children.Add(articleButton);
                        articlePanel.Children.Add(link);

                        _topicBodyPanel.Children.Add(articlePanelBorder);
                    }
                    else
                    {
                        HyperlinkButton link = new HyperlinkButton();
                        link.SetValue(TiltEffect.IsTiltEnabledProperty, true);

                        if (isSignature)
                        {
                            link.FontSize = (double)App.Current.Resources["PhoneFontSizeSmall"];
                            link.Foreground = (Brush)App.Current.Resources["PhoneSubtleBrush"];
                        }
                        else
                        {
                            link.FontSize = (double)App.Current.Resources["MitbbsFontSizeText"];
                        }

                        //link.TargetName = "_new";
                        //link.NavigateUri = new Uri((content as LinkBlock).Url, UriKind.Absolute);
                        link.Click += GeneralLink_Click;
                        link.DataContext = content;
                        link.Content = (content as LinkBlock).Text;
                        link.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                        link.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left;
                        _topicBodyPanel.Children.Add(link);
                    }
                }
                else if (content is VideoBlock)
                {
                    Button playButton = new Button();
                    ImageBrush playButtonImage = new ImageBrush();
                    playButtonImage.ImageSource = new BitmapImage(new Uri("/MitbbsReader;component/Images/play_roundbutton.png", UriKind.Relative));
                    playButtonImage.Stretch = Stretch.Uniform;
                    playButton.Style = (Style)Application.Current.Resources["ImageButton"];
                    playButton.Content = playButtonImage;
                    playButton.Padding = new Thickness(0);
                    playButton.BorderThickness = new Thickness(0);
                    playButton.Margin = new Thickness(0);

                    GestureListener gl2 = GestureService.GetGestureListener(playButton);
                    gl2.Tap += new EventHandler<Microsoft.Phone.Controls.GestureEventArgs>(GeneralButton_Tapped);

                    playButton.Click += PlayButton_Click;
                    playButton.DataContext = content;

                    HyperlinkButton link = new HyperlinkButton();
                    link.SetValue(TiltEffect.IsTiltEnabledProperty, true);

                    Border playPanelBorder = new Border();

                    if (isSignature)
                    {
                        playButton.Width = buttonSize * 2 / 3;
                        playButton.Height = buttonSize * 2 / 3;
                        playButton.Foreground = (Brush)App.Current.Resources["PhoneSubtleBrush"];
                        link.FontSize = (double)App.Current.Resources["PhoneFontSizeSmall"];
                        link.Foreground = (Brush)App.Current.Resources["PhoneSubtleBrush"];
                        playPanelBorder.BorderBrush = (Brush)App.Current.Resources["PhoneSubtleBrush"];
                        playPanelBorder.BorderThickness = new Thickness(1);
                        playPanelBorder.Width = 200;
                        playPanelBorder.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                    }
                    else
                    {
                        playButton.Width = buttonSize;
                        playButton.Height = buttonSize;
                        link.FontSize = (double)App.Current.Resources["MitbbsFontSizeText"];
                        playPanelBorder.BorderBrush = (Brush)App.Current.Resources["PhoneForegroundBrush"];
                        playPanelBorder.BorderThickness = new Thickness(2);
                        playPanelBorder.Width = 300;
                    }

                    link.Content = "点击播放视频";
                    link.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                    link.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left;
                    link.DataContext = content;

                    link.Click += VideoLink_Click;

                    StackPanel playPanel = new StackPanel() { Orientation = System.Windows.Controls.Orientation.Horizontal };

                    playPanelBorder.Child = playPanel;
                    playPanel.Children.Add(playButton);
                    playPanel.Children.Add(link);

                    _topicBodyPanel.Children.Add(playPanelBorder);
                }
                else if (content is TextContentBlock)
                {
                    String contentText = (content as TextContentBlock).Text;

                    if (firstContent)
                    {
                        if (!contentText.StartsWith("\n"))
                        {
                            contentText = "\n" + contentText;
                        }

                        firstContent = false;
                    }

                    TextBlock tb = new TextBlock();
                    tb.Text = contentText;
                    tb.TextWrapping = TextWrapping.Wrap;

                    if (content is QuoteBlock)
                    {
                        tb.Style = (Style)App.Current.Resources["PhoneTextSubtleStyle"];
                        tb.FontSize = (double)App.Current.Resources["MitbbsFontSizeNormal"];
                        Border bd = new Border();
                        Thickness bdMgn = new Thickness(0);
                        bdMgn.Left = 20;

                        bd.Margin = bdMgn;
                        bd.BorderThickness = new Thickness(1);
                        bd.CornerRadius = new CornerRadius(8);
                        bd.BorderBrush = (Brush)App.Current.Resources["PhoneSubtleBrush"];

                        bd.Child = tb;
                        _topicBodyPanel.Children.Add(bd);
                    }
                    else
                    {
                        if (isSignature)
                        {
                            tb.Style = (Style)App.Current.Resources["PhoneTextSubtleStyle"];
                            tb.FontSize = (double)App.Current.Resources["MitbbsFontSizeNormal"];
                        }

                        _topicBodyPanel.Children.Add(tb);
                    }
                }
            }

            // Padding
            //
            Grid sep = new Grid();
            sep.Margin = new Thickness(10);

            _topicBodyPanel.Children.Add(sep);
        }
Пример #29
0
        private void CreateAxisYElements4PolarChart(Double height, Double minAngleInDegree, Point point, Double angle, Double index, Point center)
        {
            AxisElementsContainer = new StackPanel() { Background = InternalBackground };
            AxisElementsContainer.Orientation = Orientation.Horizontal;

            ApplyAxisProperties4CircularChart();

            CreateAxisLine(0, height, (Double)LineThickness / 2, (Double)LineThickness / 2, (Double)LineThickness, height);

            RotateTransform transform = new RotateTransform();
            Double rotationAngleIndegree = Visifire.Commons.CircularLabel.ResetMeanAngle(CalculateAngleByCoordinate(point, center)) * 180 / Math.PI;
            transform.Angle = rotationAngleIndegree + 90;

            Double axisLabelsWidth = 0;

            if (Math.Round(minAngleInDegree) == Math.Round(rotationAngleIndegree))
            {
                AxisLabels.CreateVisualObject();

                if (AxisLabels.Visual != null)
                {
                    AxisElementsContainer.Children.Add(AxisLabels.Visual);

                    if(!Double.IsNaN(AxisLabels.Visual.Width))
                        axisLabelsWidth = AxisLabels.Visual.Width;
                }
            }

            Double ticksWidth = 0;

            List<Ticks> ticks = Ticks.Reverse().ToList();

            foreach (Ticks tick in ticks)
            {
                tick.SetParms(PlacementTypes.Left, Double.NaN, height);

                tick.CreateVisualObject();

                if (tick.Visual != null)
                {
                    AxisElementsContainer.Children.Add(tick.Visual);
                    ticksWidth += tick.Visual.Width;
                }
            }

            if (AxisLine != null)
                AxisElementsContainer.Children.Add(AxisLine);

            AxisElementsContainer.SetValue(Canvas.LeftProperty, point.X - axisLabelsWidth - ticksWidth);
            AxisElementsContainer.SetValue(Canvas.TopProperty, point.Y);

            if (transform != null)
            {
                AxisElementsContainer.RenderTransformOrigin = new Point(1, 0);
                AxisElementsContainer.RenderTransform = transform;
            }

            CircularAxisVisual.Children.Add(AxisElementsContainer);
        }
Пример #30
0
        /// <summary>
        /// Creates columns defined in the UI.
        /// </summary>
        private void CreateColumns()
        {
            if (this.columns.Count > 0)
            {
                this.mainView = new MainView();
                this.CreateGroupingColumn();

                for (int columnIndex = 0; columnIndex < this.columns.Count; columnIndex++)
                {
                    WrapDataGridColumn currentColumn = this.columns[columnIndex];

                    CheckCellTemplate(currentColumn.CellTemplate);
                    CheckHeaderTemplate(currentColumn.HeaderTemplate);

                    ColumnManager column = new ColumnManager();

                    // Load our cell template, then the ISV cell template and set grid column/row properties to isv cell template.                    
                    Grid headerTemplate = DataTemplateHelper.LoadContent((this.layoutRoot.Resources["HeaderTemplate"] as DataTemplate)) as Grid;
                    headerTemplate.SetValue(Grid.RowProperty, 1);
                    headerTemplate.SetValue(Grid.ColumnProperty, columnIndex + 1);

                    if (columnIndex + 1 == this.columns.Count)
                    {
                        // Setting colspan to 2 to cover scrollbar top
                        headerTemplate.SetValue(Grid.ColumnSpanProperty, 2);
                    }

                    // Header template
                    UIElement customHeaderTemplate = DataTemplateHelper.LoadContent(currentColumn.HeaderTemplate) as UIElement;
                    customHeaderTemplate.SetValue(Grid.ColumnProperty, 0);
                    customHeaderTemplate.SetValue(Grid.RowProperty, 0);
                    headerTemplate.Children.Add(customHeaderTemplate);

                    DataTemplate cellTemplate = this.layoutRoot.Resources["CellTemplate"] as DataTemplate;

                    // Column manager stack panel.
                    StackPanel columnStackPanel = new StackPanel();

                    columnStackPanel.SetValue(Grid.ColumnProperty, columnIndex + 1);
                    columnStackPanel.SetValue(Grid.RowProperty, 4);

                    // Set column manager properties.
                    column.MasterCellTemplate = cellTemplate;
                    column.CellTemplate = currentColumn.CellTemplate;
                    column.ColumnHeader = headerTemplate;
                    column.StackPanel = columnStackPanel;
                    column.BodyMargin = currentColumn.BodyMargin;
                    column.ToolTipTemplate = currentColumn.ToolTipTemplate;

                    // Add Column manager to column manager collection
                    this.mainViewColumns.Add(column);
                }
            }
        }