Exemple #1
0
        void UpdateOrientation()
        {
            if (orientation == Orientation.Horizontal)
            {
                splitter.ResizeDirection     = swc.GridResizeDirection.Columns;
                splitter.HorizontalAlignment = sw.HorizontalAlignment.Left;
                splitter.VerticalAlignment   = sw.VerticalAlignment.Stretch;

                splitter.SetValue(swc.Grid.RowSpanProperty, 3);
                pane1.SetValue(swc.Grid.RowSpanProperty, 3);
                pane2.SetValue(swc.Grid.RowSpanProperty, 3);

                splitter.SetValue(swc.Grid.ColumnSpanProperty, 1);
                pane1.SetValue(swc.Grid.ColumnSpanProperty, 1);
                pane2.SetValue(swc.Grid.ColumnSpanProperty, 1);

                swc.Grid.SetColumn(splitter, 1);
                swc.Grid.SetRow(splitter, 0);
                swc.Grid.SetColumn(pane2, 2);
                swc.Grid.SetRow(pane2, 0);

                splitter.Width  = splitterWidth;
                splitter.Height = double.NaN;
            }
            else
            {
                splitter.ResizeDirection     = swc.GridResizeDirection.Rows;
                splitter.HorizontalAlignment = sw.HorizontalAlignment.Stretch;
                splitter.VerticalAlignment   = sw.VerticalAlignment.Top;
                pane2.VerticalAlignment      = sw.VerticalAlignment.Stretch;

                splitter.SetValue(swc.Grid.RowSpanProperty, 1);
                pane1.SetValue(swc.Grid.RowSpanProperty, 1);
                pane2.SetValue(swc.Grid.RowSpanProperty, 1);

                splitter.SetValue(swc.Grid.ColumnSpanProperty, 3);
                pane1.SetValue(swc.Grid.ColumnSpanProperty, 3);
                pane2.SetValue(swc.Grid.ColumnSpanProperty, 3);

                swc.Grid.SetColumn(splitter, 0);
                swc.Grid.SetRow(splitter, 1);
                swc.Grid.SetColumn(pane2, 0);
                swc.Grid.SetRow(pane2, 2);

                splitter.Width  = double.NaN;
                splitter.Height = splitterWidth;
            }
            UpdateColumnSizing(position.HasValue || !double.IsNaN(relative));
        }
Exemple #2
0
        void UpdateOrientation()
        {
            if (orientation == SplitterOrientation.Horizontal)
            {
                splitter.ResizeDirection     = swc.GridResizeDirection.Columns;
                splitter.HorizontalAlignment = sw.HorizontalAlignment.Left;
                splitter.VerticalAlignment   = sw.VerticalAlignment.Stretch;

                splitter.SetValue(swc.Grid.RowSpanProperty, 3);
                pane1.SetValue(swc.Grid.RowSpanProperty, 3);
                pane2.SetValue(swc.Grid.RowSpanProperty, 3);

                splitter.SetValue(swc.Grid.ColumnSpanProperty, 1);
                pane1.SetValue(swc.Grid.ColumnSpanProperty, 1);
                pane2.SetValue(swc.Grid.ColumnSpanProperty, 1);

                swc.Grid.SetColumn(splitter, 1);
                swc.Grid.SetRow(splitter, 0);
                swc.Grid.SetColumn(pane2, 2);
                swc.Grid.SetRow(pane2, 0);

                splitter.Width  = 5;
                splitter.Height = double.NaN;
            }
            else
            {
                splitter.ResizeDirection     = swc.GridResizeDirection.Rows;
                splitter.HorizontalAlignment = sw.HorizontalAlignment.Stretch;
                splitter.VerticalAlignment   = sw.VerticalAlignment.Top;
                pane2.VerticalAlignment      = sw.VerticalAlignment.Stretch;

                splitter.SetValue(swc.Grid.RowSpanProperty, 1);
                pane1.SetValue(swc.Grid.RowSpanProperty, 1);
                pane2.SetValue(swc.Grid.RowSpanProperty, 1);

                splitter.SetValue(swc.Grid.ColumnSpanProperty, 3);
                pane1.SetValue(swc.Grid.ColumnSpanProperty, 3);
                pane2.SetValue(swc.Grid.ColumnSpanProperty, 3);

                swc.Grid.SetColumn(splitter, 0);
                swc.Grid.SetRow(splitter, 1);
                swc.Grid.SetColumn(pane2, 0);
                swc.Grid.SetRow(pane2, 2);

                splitter.Width  = double.NaN;
                splitter.Height = 5;
            }
        }
Exemple #3
0
        private void InternalArrange(Grid grid, IPane pane)
        {
            if (pane is UIElement)
            {
                grid.Children.Add(pane as UIElement);
            }
            else if (pane is PaneGroup)
            {
                PaneGroup group = pane as PaneGroup;
                if (group.First.Hidden && !group.Second.Hidden)
                    InternalArrange(grid, group.Second);
                else if (!group.First.Hidden && group.Second.Hidden)
                    InternalArrange(grid, group.First);
                else
                {
                    Grid firstGrid = new Grid();
                    Grid secondGrid = new Grid();

                    if (group.Split == SplitOrientation.Horizontal)
                    {
                        grid.ColumnDefinitions.Add(new ColumnDefinition());
                        grid.RowDefinitions.Add(new RowDefinition());
                        grid.RowDefinitions.Add(new RowDefinition());

                        grid.RowDefinitions[0].Height = group.First.GridHeight;
                        grid.RowDefinitions[1].Height = group.Second.GridHeight;

                        //if (!grid.RowDefinitions[0].Height.IsStar &&
                        //    !grid.RowDefinitions[1].Height.IsStar)
                        //    grid.RowDefinitions[1].Height = new GridLength(1, GridUnitType.Star);

                        firstGrid.SetValue(Grid.ColumnProperty, 0);
                        firstGrid.SetValue(Grid.RowProperty, 0);
                        secondGrid.SetValue(Grid.ColumnProperty, 0);
                        secondGrid.SetValue(Grid.RowProperty, 1);

                        GridSplitter splitter = new GridSplitter();
                        splitter.VerticalAlignment = VerticalAlignment.Top;
                        splitter.HorizontalAlignment = HorizontalAlignment.Stretch;
                        splitter.SetValue(Grid.ColumnProperty, 0);
                        splitter.SetValue(Grid.RowProperty, 1);
                        splitter.Height = 5;
                        secondGrid.Margin = new Thickness(0, 5, 0, 0);

                        grid.Children.Add(firstGrid);
                        grid.Children.Add(splitter);
                        grid.Children.Add(secondGrid);

                        InternalArrange(firstGrid, group.First);
                        InternalArrange(secondGrid, group.Second);
                    }
                    else
                    {
                        grid.ColumnDefinitions.Add(new ColumnDefinition());
                        grid.ColumnDefinitions.Add(new ColumnDefinition());
                        grid.RowDefinitions.Add(new RowDefinition());

                        grid.ColumnDefinitions[0].Width = group.First.GridWidth;
                        grid.ColumnDefinitions[1].Width = group.Second.GridWidth;
                        if (!grid.ColumnDefinitions[0].Width.IsStar &&
                            !grid.ColumnDefinitions[1].Width.IsStar)
                            grid.ColumnDefinitions[1].Width = new GridLength(1, GridUnitType.Star);

                        firstGrid.SetValue(Grid.ColumnProperty, 0);
                        firstGrid.SetValue(Grid.RowProperty, 0);
                        secondGrid.SetValue(Grid.ColumnProperty, 1);
                        secondGrid.SetValue(Grid.RowProperty, 0);

                        GridSplitter splitter = new GridSplitter();
                        splitter.VerticalAlignment = VerticalAlignment.Stretch;
                        splitter.HorizontalAlignment = HorizontalAlignment.Left;
                        splitter.SetValue(Grid.ColumnProperty, 1);
                        splitter.SetValue(Grid.RowProperty, 0);
                        splitter.Width = 5;
                        secondGrid.Margin = new Thickness(5, 0, 0, 0);

                        grid.Children.Add(firstGrid);
                        grid.Children.Add(splitter);
                        grid.Children.Add(secondGrid);

                        InternalArrange(firstGrid, group.First);
                        InternalArrange(secondGrid, group.Second);
                    }
                }
            }
        }
Exemple #4
0
        private void InitializeComponent(Configuration cfg)
        {
            this.Width = 1024;
            this.Height = 768;

            Button btnNew = NewImageButton(ApplicationCommands.New, "New", "New(Ctrl-N)", "New_16x16.png");
            Button btnOpen = NewImageButton(ApplicationCommands.Open, "Open", "Open(Ctrl-O)", "Open_16x16.png");
            Button btnSave = NewImageButton(ApplicationCommands.Save, "Save", "Save(Ctrl-S)", "Save_16x16.png");
            Button btnExecute = NewImageButton(ExecuteCommand, "Execute", "Execute(F5)", "Next_16x16.png");

            DockPanel dockPanel = new DockPanel();
            this.Content = dockPanel;

            //Tool bar
            ToolBarTray tray = new ToolBarTray();
            tray.SetValue(DockPanel.DockProperty, Dock.Top);
            dockPanel.Children.Add(tray);

            ToolBar toolBar;
            tray.ToolBars.Add(toolBar = new ToolBar());
            toolBar.Items.Add(btnNew);
            toolBar.Items.Add(btnOpen);
            toolBar.Items.Add(btnSave);
            tray.ToolBars.Add(toolBar = new ToolBar());
            toolBar.Items.Add(btnExecute);

            //status bar
            StatusBar statusBar = new StatusBar { Height = 20 };
            statusBar.Items.Add(new StatusBarItem { Content = lblMessage, HorizontalAlignment = HorizontalAlignment.Left });
            statusBar.Items.Add(new StatusBarItem { Content = lblCursorPosition, HorizontalAlignment = HorizontalAlignment.Right });
            statusBar.Items.Add(new StatusBarItem { Content = lblRowCount, HorizontalAlignment = HorizontalAlignment.Right });
            statusBar.SetValue(DockPanel.DockProperty, Dock.Bottom);
            dockPanel.Children.Add(statusBar);

            #region editor and results
            Grid grid = new Grid();
            grid.RowDefinitions.Add(new RowDefinition());
            grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(5) });
            grid.RowDefinitions.Add(new RowDefinition());

            dockPanel.Children.Add(grid);
            textBox.Foreground = cfg.GetSolidBrush("gui.sql.editor.Foreground", Colors.Black);
            textBox.Background = cfg.GetSolidBrush("gui.sql.editor.Background", Colors.White);

            //Paragraph space
            Style style = new Style { TargetType = typeof(Paragraph) };
            style.Setters.Add(new Setter { Property = Block.MarginProperty, Value = new Thickness(0) });
            textBox.Resources.Add(typeof(Paragraph), style);

            GridSplitter splitter = new GridSplitter { Height = 5, HorizontalAlignment = HorizontalAlignment.Stretch };
            tabControl.Foreground = cfg.GetSolidBrush("gui.sql.editor.Foreground", Colors.Black);
            tabControl.Background = cfg.GetSolidBrush("gui.sql.editor.Background", Colors.White);

            textBox.SetValue(Grid.RowProperty, 0);
            splitter.SetValue(Grid.RowProperty, 1);
            tabControl.SetValue(Grid.RowProperty, 2);
            grid.Children.Add(textBox);
            grid.Children.Add(splitter);
            grid.Children.Add(tabControl);

            #endregion

            CommandBinding binding;
            RoutedUICommand[] commands = new RoutedUICommand[]
               {
                  ApplicationCommands.New,
                  ApplicationCommands.Open,
                  ApplicationCommands.Save,
                  ExecuteCommand
               };

            foreach (var cmd in commands)
            {
                binding = new CommandBinding(cmd);
                binding.Executed += commandExecute;
                binding.CanExecute += commandCanExecute;
                this.CommandBindings.Add(binding);
            }
        }
Exemple #5
0
        internal void SplitViewHorizontally(ITextView textView)
        {
            m_dockPanel.Children.Clear();
            _textViewHostList.Add(CreateTextViewHost());

            var grid = BuildGrid();
            var row = 0;
            for (int i = 0; i < _textViewHostList.Count; i++)
            {
                var textViewHost = _textViewHostList[i];
                var control = textViewHost.HostControl;
                control.SetValue(Grid.RowProperty, row++);
                control.SetValue(Grid.ColumnProperty, 0);
                grid.Children.Add(control);

                if (i + 1 < _textViewHostList.Count)
                {
                    var splitter = new GridSplitter();
                    splitter.ResizeDirection = GridResizeDirection.Rows;
                    splitter.HorizontalAlignment = HorizontalAlignment.Stretch;
                    splitter.VerticalAlignment = VerticalAlignment.Stretch;
                    splitter.ShowsPreview = true;
                    splitter.SetValue(Grid.RowProperty, row++);
                    splitter.SetValue(Grid.ColumnProperty, 0);
                    splitter.Height = 5;
                    splitter.Background = Brushes.Black;
                    grid.Children.Add(splitter);
                }
            }

            m_dockPanel.Children.Add(grid);
        }
Exemple #6
0
        private Grid BuildGrid(ReadOnlyCollection<IVimViewInfo> viewInfoList)
        {
            Contract.Requires(viewInfoList.Count > 1);
            var grid = BuildGridCore(viewInfoList);
            var row = 0;
            for (int i = 0; i < viewInfoList.Count; i++)
            {
                var viewInfo = viewInfoList[i];
                var textViewHost = viewInfo.TextViewHost;
                var control = textViewHost.HostControl;
                control.SetValue(Grid.RowProperty, row++);
                control.SetValue(Grid.ColumnProperty, 0);
                grid.Children.Add(control);

                if (i + 1 < viewInfoList.Count)
                {
                    var splitter = new GridSplitter();
                    splitter.ResizeDirection = GridResizeDirection.Rows;
                    splitter.HorizontalAlignment = HorizontalAlignment.Stretch;
                    splitter.VerticalAlignment = VerticalAlignment.Stretch;
                    splitter.ShowsPreview = true;
                    splitter.SetValue(Grid.RowProperty, row++);
                    splitter.SetValue(Grid.ColumnProperty, 0);
                    splitter.Height = 5;
                    splitter.Background = Brushes.Black;
                    grid.Children.Add(splitter);
                }
            }

            return grid;
        }
Exemple #7
0
        void reportGenerator_ResultsChange(object sender, ReportGenerator.ResultsChangedEventArgs results)
        {
            //Updating Charts
            var plotData = results.CurrentResults;
            if (plotData != null && plotData.Tests.Count > 0)
            {
                //Preparing Grid
                System.Windows.Threading.DispatcherOperation
                    dispatcherOp = ChartsGrid.Dispatcher.BeginInvoke(
                        System.Windows.Threading.DispatcherPriority.Normal,
                        new Action(
                            delegate()
                            {
                                if (plotData.Tests.Count != ChartsGrid.RowDefinitions.Count)
                                {
                                    //Removing charts
                                    ChartsGrid.Children.Clear();
                                    ChartsGrid.RowDefinitions.Clear();
                                    //Adding components
                                    var plot1 = new OxyPlot.Wpf.Plot() { Height = 500 };
                                    plot1.Name = "chart0_0";
                                    plot1.SetValue(Grid.RowProperty, 0);
                                    plot1.SetValue(Grid.ColumnProperty, 0);
                                    plot1.BorderBrush = new SolidColorBrush(Colors.Black);
                                    plot1.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                                    var split = new GridSplitter() { Width = 4 };
                                    var plot2 = new OxyPlot.Wpf.Plot() { Height = 500 };
                                    plot2.Name = "chart0_1";
                                    plot2.SetValue(Grid.RowProperty, 0);
                                    plot2.SetValue(Grid.ColumnProperty, 1);
                                    plot2.BorderBrush = new SolidColorBrush(Colors.Black);
                                    plot2.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                                    ChartsGrid.Children.Add(plot1);
                                    ChartsGrid.Children.Add(split);
                                    ChartsGrid.Children.Add(plot2);
                                    ChartsGrid.Height = 700;
                                    ChartsGrid.RowDefinitions.Add(new RowDefinition() { });
                                    if (plotData.Tests.Count > 1)
                                    {
                                        for (int i = 1; i < plotData.Tests.Count; i++)
                                        {
                                            var plot3 = new OxyPlot.Wpf.Plot() { Height = 500 };
                                            plot3.Name = String.Format("chart{0}_0", i);
                                            plot3.SetValue(Grid.RowProperty, i);
                                            plot3.SetValue(Grid.ColumnProperty, 0);
                                            plot3.BorderBrush = new SolidColorBrush(Colors.Black);
                                            plot3.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                                            var split1 = new GridSplitter() { Width = 4 };
                                            split1.SetValue(Grid.RowProperty, i);
                                            var plot4 = new OxyPlot.Wpf.Plot() { Height = 500 };
                                            plot4.Name = String.Format("chart{0}_1", i);
                                            plot4.SetValue(Grid.RowProperty, i);
                                            plot4.SetValue(Grid.ColumnProperty, 1);
                                            plot4.BorderBrush = new SolidColorBrush(Colors.Black);
                                            plot4.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                                            ChartsGrid.Children.Add(plot3);
                                            ChartsGrid.Children.Add(split1);
                                            ChartsGrid.Children.Add(plot4);
                                            ChartsGrid.RowDefinitions.Add(new RowDefinition() { });
                                        }
                                        ChartsGrid.Height = plotData.Tests.Count * 500 + plotData.Tests.Count * 4;
                                    }
                                    ChartsGrid.UpdateLayout();
                                }
                            }));
                //For all Tests in Tests Data
                for (int testIndex = 0; testIndex < plotData.Tests.Count; testIndex++)
                {
                    var test = plotData.Tests[testIndex];
                    //Creating Model for Time
                    var tmp = new PlotModel("Duration", "using OxyPlot and NPerf");
                    if (isLogarithmic)
                    {
                        tmp.Axes.Add(new LogarithmicAxis(AxisPosition.Right, "Logarithmic"));
                    }
                    tmp.Title = "Duration (" + test.Name + ")";
                    int typeIndex = 0;
                    int testIndexInner = testIndex;

                    var runTotal = test.Runs[0];
                    var series =
                        (from PerfResult trun in runTotal.Results
                         select new LineSeries(trun.TestedType) { MarkerType = MarkerType.Circle }).Cast<Series>().ToList();

                    foreach (var run in test.Runs)
                    {
                        typeIndex = 0;
                        foreach (var trun in run.Results)
                        {
                            if (typeIndex < run.Results.Count)
                            {
                                //Series name: run.Results[index].testedtype
                                // Value -> run.Results[index]
                                (series[typeIndex] as LineSeries).Points.Add(new DataPoint(run.Value,
                                                                                           run.Results[typeIndex].
                                                                                               Duration));
                            }
                            typeIndex++;
                        }
                    }
                    tmp.Series = new System.Collections.ObjectModel.Collection<Series>(series);

                    //Creating model for Memory
                    var tmp1 = new PlotModel("Memory", "using OxyPlot and NPerf");
                    if (isLogarithmic)
                    {
                        tmp1.Axes.Add(new LogarithmicAxis(AxisPosition.Right, "Logarithmic"));
                    }
                    typeIndex = 0;
                    tmp1.Title = "Memory (" + test.Name + ")";
                    var runTotal1 = test.Runs[0];
                    var series1 =
                        (from PerfResult trun in runTotal1.Results
                         select new LineSeries(trun.TestedType) { MarkerType = MarkerType.Circle }).Cast<Series>().ToList();
                    foreach (var run in test.Runs)
                    {
                        typeIndex = 0;
                        foreach (var trun in run.Results)
                        {
                            if (typeIndex < run.Results.Count)
                            {
                                //Series name: run.Results[index].testedtype
                                // Value -> run.Results[index]
                                (series1[typeIndex] as LineSeries).Points.Add(new DataPoint(run.Value,
                                                                                            run.Results[typeIndex].
                                                                                                MemoryUsageMb));
                            }
                            typeIndex++;
                        }
                    }
                    tmp1.Series = new System.Collections.ObjectModel.Collection<Series>(series1);

                    System.Windows.Threading.DispatcherOperation
                        dispatcherOp1 = ChartsGrid.Dispatcher.BeginInvoke(
                            System.Windows.Threading.DispatcherPriority.Normal,
                            new Action(
                                delegate()
                                {
                                    //Setting models
                                    foreach (var el in ChartsGrid.Children)
                                    {
                                        if (el is OxyPlot.Wpf.Plot &&
                                            (el as OxyPlot.Wpf.Plot).Name.Equals(String.Format("chart{0}_0",
                                                                                               testIndexInner)))
                                        {
                                            (el as OxyPlot.Wpf.Plot).Model = tmp;
                                            break;
                                        }
                                    }
                                    foreach (var el in ChartsGrid.Children)
                                    {
                                        if (el is OxyPlot.Wpf.Plot &&
                                            (el as OxyPlot.Wpf.Plot).Name.Equals(String.Format("chart{0}_1",
                                                                                               testIndexInner)))
                                        {
                                            (el as OxyPlot.Wpf.Plot).Model = tmp1;
                                            break;
                                        }
                                    }
                                    ChartsGrid.UpdateLayout();
                                }
                                ));
                }
            }
        }
        private bool PopulateIEntityAttributes(object obj)
        {
            EntityViewModel entity = obj as EntityViewModel;

             if (entity == null)
            return false;

             int rc = 0;
             foreach ( var attr in entity.Entity.Attributes )
             {
            RowDefinition rd = new RowDefinition();
            Properties.RowDefinitions.Add(rd);
            rd.MaxHeight = 20;
            ++rc;

            Border borderPname = new Border();
            borderPname.BorderBrush = Brushes.Black;
            borderPname.BorderThickness = new Thickness(0.5);

            // Add Property Name
            TextBlock tb = new TextBlock();
            tb.Margin = new Thickness(2);
            tb.Text = attr.Key;
            tb.TextAlignment = TextAlignment.Left;
            tb.VerticalAlignment = VerticalAlignment.Center;
            borderPname.Child = tb;
            Properties.Children.Add(borderPname);

            borderPname.SetValue(Grid.RowProperty, rc);
            borderPname.SetValue(Grid.ColumnProperty, 0);

            // Add Value
            TextBox edit = new TextBox();
            Binding valueBinding = new Binding();

            valueBinding.Path = new PropertyPath("Value");
            valueBinding.Source = new ValueWrapper(attr.Key, entity.Entity);
            edit.SetBinding(TextBox.TextProperty, valueBinding);

            Properties.Children.Add(edit);

            edit.SetValue(Grid.RowProperty, rc);
            edit.SetValue(Grid.ColumnProperty, 2);
             }

             GridSplitter gs = new GridSplitter();
             gs.ResizeDirection = GridResizeDirection.Columns;
             gs.ShowsPreview = true;
             gs.SnapsToDevicePixels = true;
             Properties.Children.Add(gs);
             gs.SetValue(Grid.ColumnProperty, 1);

             return true;
        }
        private void Redraw()
        {
            var properties = TypeDescriptor.GetProperties(viewModel.CollectionElementType).OfType<PropertyDescriptor>().Where(x => x.Attributes.OfType<ConfigurationPropertyAttribute>().Any()).ToArray();

            for (int n = 0; n <= viewModel.ChildElements.Count() + 1; n++)
            {
                Collection.RowDefinitions.Add(new RowDefinition());
            }

            int i = 0;
            foreach (var property in properties)
            {
                var label = new Label() { Content = property.DisplayName };
                Collection.Children.Add(label);
                label.SetValue(Grid.RowProperty, 0);
                label.SetValue(Grid.ColumnProperty, i);


                var gridSplitter = new GridSplitter() { Width = 2, HorizontalAlignment = HorizontalAlignment.Right };
                Collection.Children.Add(gridSplitter);
                gridSplitter.Focusable = false;
                gridSplitter.SetValue(Grid.RowProperty, 0);
                gridSplitter.SetValue(Grid.ColumnProperty, i);
                gridSplitter.SetValue(Grid.RowSpanProperty, viewModel.ChildElements.Count() + 1);
                i++;
            }

            ContextMenuButton addButton = new ContextMenuButton();
            Collection.Children.Add(addButton);
            CommandModel addCommand = viewModel.AddCommands.First();
            addButton.Command = addCommand;
            addButton.SetValue(Grid.RowProperty, 0);
            addButton.SetValue(Grid.ColumnProperty, i);
            addButton.Style = FindResource("ContextAdderButtonMenuStyle") as Style;
            addButton.VerticalAlignment = VerticalAlignment.Center;
            addButton.SetValue(AutomationProperties.AutomationIdProperty, addCommand.Title);
            
            int j = 1;
            foreach (var element in viewModel.ChildElements)
            {
                i = 0;
                foreach (var propertyDescriptor in properties)
                {
                    var property = element.Property(propertyDescriptor.Name);

                    ContentControl contentControl = new ContentControl();
                    contentControl.Focusable = false;
                    Collection.Children.Add(contentControl);
                    contentControl.SetValue(ContentControl.ContentProperty, property.BindableProperty);
                    contentControl.SetValue(Grid.RowProperty, j);
                    contentControl.SetValue(Grid.ColumnProperty, i);

                    i++;
                }

                Button deleteButton = new Button();
                Collection.Children.Add(deleteButton);
                CommandModel deleteCommand = element.Commands.Where(x => x.Placement == CommandPlacement.ContextDelete).First();
                deleteButton.Command = deleteCommand;
                deleteButton.SetValue(Grid.RowProperty, j);
                deleteButton.SetValue(Grid.ColumnProperty, i);
                deleteButton.Style = FindResource("DeleteButtonStyle") as Style;
                deleteButton.VerticalAlignment = VerticalAlignment.Center;
                deleteButton.SetValue(AutomationProperties.AutomationIdProperty, deleteCommand.Title);

                j++;
            }
        }
        internal void SplitViewHorizontally(IWpfTextView textView)
        {
            var tabInfo = ActiveTabInfo;
            var newTextViewHost = CreateTextViewHost(textView);
            var vimBuffer = _vimComponentHost.Vim.GetOrCreateVimBuffer(textView);
            tabInfo.AddViewInfo(vimBuffer, newTextViewHost);

            var viewInfoList = tabInfo.ViewInfoList.ToList();
            var grid = BuildGrid(viewInfoList);
            var row = 0;
            for (int i = 0; i < viewInfoList.Count; i++)
            {
                var viewInfo = viewInfoList[i];
                var textViewHost = viewInfo.TextViewHost;
                var control = textViewHost.HostControl;
                control.SetValue(Grid.RowProperty, row++);
                control.SetValue(Grid.ColumnProperty, 0);
                grid.Children.Add(control);

                if (i + 1 < viewInfoList.Count)
                {
                    var splitter = new GridSplitter();
                    splitter.ResizeDirection = GridResizeDirection.Rows;
                    splitter.HorizontalAlignment = HorizontalAlignment.Stretch;
                    splitter.VerticalAlignment = VerticalAlignment.Stretch;
                    splitter.ShowsPreview = true;
                    splitter.SetValue(Grid.RowProperty, row++);
                    splitter.SetValue(Grid.ColumnProperty, 0);
                    splitter.Height = 5;
                    splitter.Background = Brushes.Black;
                    grid.Children.Add(splitter);
                }
            }

            tabInfo.TabItem.Content = grid;
        }
Exemple #11
0
        private void ReloadPluginsComplete()
        {
            int count = _context.Plugins.Count;
            // create Grid.RowDefinitions
            for (var i = 0; i < count; i++)
            {
                ContentGrid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(1, GridUnitType.Star)});
                if (i != count - 1)
                {
                    ContentGrid.RowDefinitions.Add(new RowDefinition {Height = GridLength.Auto});
                }
            }

            // Create GridSplitters
            for (var s = 0; s < count - 1; s++)
            {
                var spl = new GridSplitter
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Height = 5,
                    Tag = s
                };
                spl.SetValue(Grid.RowProperty, s*2 + 1);
                ContentGrid.Children.Add(spl);
            }
            // Create and start Plugins
            for (var c = 0; c < count; c++)
            {
                var plugin = _context.Plugins[c];
                var child = plugin.PluginControl;
                child.Margin = new Thickness(5);
                child.SetValue(Grid.RowProperty, c*2);
                ContentGrid.Children.Add(child);
                (new Task(() => StartAndRefreshPlugin(plugin))).Start();
            }
        }
        /// <summary>
        /// Add a panel to the display grid.
        /// </summary>
        private void AddPanelToDisplay(object sender, RoutedEventArgs args)
        {
            GridSplitter gridSplitter;
            IRegisteredPanel nextPanel = (IRegisteredPanel)sender;
            
            // Add the next panel
            ((UserControl)nextPanel).SetValue(Grid.RowProperty, ContentAreaGrid.RowDefinitions.Count);
            ContentAreaGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            ContentAreaGrid.Children.Add((UserControl)nextPanel);

            // Add a GridSplitter
            gridSplitter = new GridSplitter() { Height = 4.0d, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 3, 0, 3), Background = new SolidColorBrush(Colors.Transparent) };
            gridSplitter.SetValue(Grid.RowProperty, ContentAreaGrid.RowDefinitions.Count);
            gridSplitter.SetValue(Grid.ColumnProperty, 0);
            ContentAreaGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            ContentAreaGrid.Children.Add(gridSplitter);
        }
        /// <summary>
        /// Re-render the panels displayed from the selected panel collection.
        /// </summary>
        private void UpdatePanelsFromCollection(IPanelCollection panelCollection)
        {
            GridSplitter gridSplitter;
            System.Windows.Controls.MenuItem menuItem;

            // Prepare the Panels for Removal
            if (_selectedPanelCollection != null)
            {
                foreach (IRegisteredPanel nextPanel in _selectedPanelCollection.Panels)
                {
                    // Notify them to Pause Monitoring
                    nextPanel.PauseMonitoring();

                    // Unregister this MainWindow's event handlers from the Panel's events
                    nextPanel.UnRegisterEventHandler(Variables.REGISTERED_EVENT_TYPE_HIDE_PANEL, RemovePanelFromDisplay);
                    nextPanel.UnRegisterEventHandler(Variables.REGISTERED_EVENT_TYPE_SHOW_PANEL, AddPanelToDisplay);
                }
            }

            // Change Collections
            _selectedPanelCollection = panelCollection;

            // Clear out the Content Area
            ContentAreaGrid.Children.Clear();
            ContentAreaGrid.RowDefinitions.Clear();

            // Remove all menu items
            menAvailablePanels.Items.Clear();

            // Build the Row Definitions for the Home Panels and Add the panels
            foreach (IRegisteredPanel nextPanel in _selectedPanelCollection.Panels)
            {
                // Add the panel to available panels menu
                menuItem = new System.Windows.Controls.MenuItem();
                menuItem.Header = new Label() { Content = nextPanel.Title, Padding = new Thickness(0.0d) };
                menuItem.IsCheckable = true;
                menuItem.IsChecked = nextPanel.IsShown;

                // Register the panel's event handlers to the MenuItem's events
                menuItem.Checked += nextPanel.ShowPanel;
                menuItem.Unchecked += nextPanel.HidePanel;

                // Register this MainWindow's event handlers to the Panel's events
                nextPanel.RegisterEventHandler(Variables.REGISTERED_EVENT_TYPE_HIDE_PANEL, RemovePanelFromDisplay);
                nextPanel.RegisterEventHandler(Variables.REGISTERED_EVENT_TYPE_SHOW_PANEL, AddPanelToDisplay);

                menAvailablePanels.Items.Add(menuItem);

                // Add the Panel to be displayed
                if (nextPanel.IsShown)
                {
                    // Add the next panel
                    ((UserControl)nextPanel).SetValue(Grid.RowProperty, ContentAreaGrid.RowDefinitions.Count);
                    ((UserControl)nextPanel).SetValue(Grid.ColumnProperty, 0);
                    ContentAreaGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
                    ContentAreaGrid.Children.Add((UserControl)nextPanel);

                    // Unpause the next panel
                    if (nextPanel.IsPaused)
                    {
                        nextPanel.UnPauseMonitoring();
                    }
                    else
                    {
                        nextPanel.StartMonitoring(ELM327Connection.Connection);
                    }

                    // Add a GridSplitter
                    gridSplitter = new GridSplitter() { Height = 4.0d, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 3, 0, 3), Background = new SolidColorBrush(Colors.Transparent) };
                    gridSplitter.SetValue(Grid.RowProperty, ContentAreaGrid.RowDefinitions.Count);
                    gridSplitter.SetValue(Grid.ColumnProperty, 0);
                    ContentAreaGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
                    ContentAreaGrid.Children.Add(gridSplitter);
                }
            }
        }
Exemple #14
0
 /// <summary>
 /// Creates a GridSplitter as the default resizer for the grid.
 /// </summary>
 /// <returns>Grid splitter.</returns>
 private GridSplitter GetDefaultResizer()
 {
     GridSplitter resizerSplitter = new GridSplitter();
     resizerSplitter.SetValue(Canvas.ZIndexProperty, 5);
     resizerSplitter.Height = 20;
     resizerSplitter.HorizontalAlignment = HorizontalAlignment.Right;
     resizerSplitter.Width = 2;
     resizerSplitter.Background = new SolidColorBrush(Colors.Gray);
     resizerSplitter.Margin = new Thickness(2, 0, 2, 0);
     resizerSplitter.IsTabStop = false;
     resizerSplitter.MouseLeftButtonUp += new MouseButtonEventHandler(this.ResizerSplitter_MouseLeftButtonUp);
     return resizerSplitter;
 }
		static GridSplitter CreateGridSplitter(int column)
		{
			GridSplitter splitter = new GridSplitter() { Width = 5, HorizontalAlignment = HorizontalAlignment.Left };
			splitter.SetValue(Grid.ColumnProperty, column);
			return splitter;
		}
        internal void AddColumn(ExcelColumn column)
        {
            int currentIndex = NoOfColumns;

            // Add the column definitions for the header and the data grid
            ColumnDefinition colDefHeader = new ColumnDefinition();
            ColumnDefinition colDefMain = new ColumnDefinition();

            colDefHeader.Width = new GridLength(column.Width);
            colDefMain.Width = new GridLength(column.Width);

            grdHeaderGrid.ColumnDefinitions.Add(colDefHeader);
            grdMain.ColumnDefinitions.Add(colDefMain);

            // Bind the grid columns width to the header column widths
            // Only works in SL4 so need to use mousemove on the splitter instead
            //Binding bdnWidth = new Binding();
            //bdnWidth.Source = colDefHeader;
            //bdnWidth.Path = new PropertyPath("Width");
            //BindingOperations.SetBinding(colDefMain, ColumnDefinition.WidthProperty, bdnWidth);
        
            // Create the header control and add it to the header
            CellHeaderControl newHeader = new CellHeaderControl();

                Binding colorBinding = new Binding("HeaderColor");
                colorBinding.Source = this;
                newHeader.SetBinding(CellHeaderControl.BackgroundColorProperty, colorBinding);
           
            newHeader.Text = column.Header;
            newHeader.HeaderFontColor = HeaderFontColor;
            newHeader.HeaderFontFamily = HeaderFontFamily;
            newHeader.HeaderFontWeight = HeaderFontWeight;
            newHeader.HeaderFontSize = HeaderFontSize;
            newHeader.SetValue(Grid.RowProperty, 0);
            newHeader.SetValue(Grid.ColumnProperty, currentIndex);
            grdHeaderGrid.Children.Add(newHeader);

            column.Control = newHeader;
            newHeader.ExcelColumn = column;
            if (column.Width == 0)
            {
                colDefHeader.Width = new GridLength((int)newHeader.TextWidth + 40);
                ResizeMainColumn(currentIndex, colDefHeader.Width);
            }
            // Create th gridSplitter control and add it to the header.
            GridSplitter splitter = new GridSplitter();
            splitter.SetValue(Grid.RowProperty, 0);
            splitter.SetValue(Grid.ColumnProperty, currentIndex);
            splitter.Style = (Style)Resources["ColSplitter"];
            splitter.Background = HeaderBorderBrush;
            splitter.MouseMove += new MouseEventHandler(splitter_MouseMove);
            grdHeaderGrid.Children.Add(splitter);
        }