public ButtonMaximizeForm()
 {
     Button = new RanetButton();
     Button.Width = Button.Height = 16;
     this.Content = Button;
     IsMaximized = false;
 }
        public VerticalExpander()
        {
            headerColumnDefinition = new ColumnDefinition();
            headerColumnDefinition.Width = GridLength.Auto;
            base.ColumnDefinitions.Add(headerColumnDefinition);
            base.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(0.0, GridUnitType.Pixel) });
            base.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1.0, GridUnitType.Star) });

            StackPanel header = new StackPanel();
            header.Orientation = Orientation.Vertical;
            base.Children.Add(header);

            m_ExpandButton = new RanetButton();
            Image icon = new Image();
            icon.Source = UriResources.Images.ForwardDouble16;
            m_ExpandButton.Content = icon;
            m_ExpandButton.Width = 20;
            m_ExpandButton.Height = 20;
            m_ExpandButton.Click += new RoutedEventHandler(ExpandButton_Click);
            header.Children.Add(m_ExpandButton);

            m_Caption = new TextBlock();
            m_Caption.RenderTransform = new RotateTransform() { Angle = 90, CenterX = 5, CenterY = 20 };
            header.Children.Add(m_Caption);

            //m_Content = new ContentControl();
            //m_Content.VerticalAlignment = VerticalAlignment.Stretch;
            //m_Content.HorizontalAlignment = HorizontalAlignment.Stretch;
        }
        public PropertiesDialog()
        {
            Dlg = new FloatingDialog();
            Dlg.MinHeight = 150;
            Dlg.MinWidth = 200;

            Dlg.Height = 300;
            Dlg.Width = 400;

            Dlg.Caption = Localization.PropertiesDialog_Caption;

            Grid container = new Grid();
            container.Margin = new Thickness(5, 5, 5, 5);
            container.RowDefinitions.Add(new RowDefinition());
            container.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

            PropertiesControl = new PropertiesControl();
            container.Children.Add(PropertiesControl);

            // Кнопки диалога
            StackPanel buttonsPanel = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right };
            container.Children.Add(buttonsPanel);
            Grid.SetRow(buttonsPanel, 3);
            RanetButton OkButton = new RanetButton() { Width = 70, Height = 22, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 5, 0, 0) };
            OkButton.Content = "OK";
            OkButton.Click += (ev_sender, args) => { Dlg.Close(); };
            buttonsPanel.Children.Add(OkButton);

            Dlg.SetContent(container);
        }
        public PopUpContainerControl()
        {
            LayoutRoot = new Grid(){Background = new SolidColorBrush(Colors.White) };
            LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition());
            LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto});


            SelectedItemTextBox = new SimpleTextBox(){ IsReadOnly = true, IsTabStop = false };
            SelectedItemTextBox.VerticalAlignment = VerticalAlignment.Stretch;
            SelectedItemTextBox.Margin = new Thickness(0);
            SelectedItemTextBox.Padding = new Thickness(2, 0, 0, 0);
            SelectedItemTextBox.VerticalContentAlignment = VerticalAlignment.Center;
            SelectedItemTextBox.Background = new SolidColorBrush(Colors.White);
            LayoutRoot.Children.Add(SelectedItemTextBox);

            m_SelectButton = new RanetButton();
            LayoutRoot.Children.Add(m_SelectButton);
            m_SelectButton.Margin = new Thickness(-1, 0, 0, 0);
            m_SelectButton.Content = "...";
            //m_SelectButton.Width = 18;
            //m_SelectButton.Height = 18;
//            selectButton.Template = this.Resources["BmButton"] as ControlTemplate;

            m_SelectButton.Click += new RoutedEventHandler(Button_Click);
            Grid.SetColumn(m_SelectButton, 1);

            this.Height = 20;

            this.Content = LayoutRoot;
        }
        public MeasureChoiceDialog()
        {
            m_Dialog = new FloatingDialog();
            m_Dialog.Caption = Localization.MeasureChoice_Caption + "...";

            Grid PopUpLayoutRoot = new Grid();
            PopUpLayoutRoot.RowDefinitions.Add(new RowDefinition() { });
            PopUpLayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

            // Контрол выбора
            m_ChoiceControl = new MeasureChoiceCtrl();
            m_ChoiceControl.Margin = new Thickness(5);
            m_ChoiceControl.ApplySelection += new EventHandler(m_ChoiceControl_ApplySelection);
            m_ChoiceControl.SelectedItemChanged += new EventHandler<Ranet.AgOlap.Controls.General.ItemEventArgs>(m_ChoiceControl_SelectedItemChanged);

            // Кнопки OK и Cancel
            StackPanel buttonsPanel = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right };
            buttonsPanel.Margin = new Thickness(5, 0, 5, 5);

            OkButton = new RanetButton() { Width = 75, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 0, 10, 0) };
            OkButton.Content = Localization.DialogButton_Ok;
            OkButton.Click += new RoutedEventHandler(OkButton_Click);
            buttonsPanel.Children.Add(OkButton);

            RanetButton CancelButton = new RanetButton() { Width = 75, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 0, 0, 0) };
            CancelButton.Content = Localization.DialogButton_Cancel;
            CancelButton.Click += new RoutedEventHandler(CancelButton_Click);
            buttonsPanel.Children.Add(CancelButton);

            PopUpLayoutRoot.Children.Add(m_ChoiceControl);
            PopUpLayoutRoot.Children.Add(buttonsPanel);
            Grid.SetRow(buttonsPanel, 1);

            m_Dialog.SetContent(PopUpLayoutRoot);
            m_Dialog.DialogClosed += new EventHandler<DialogResultArgs>(m_Dialog_DialogClosed);
            m_Dialog.Width = 500;
            m_Dialog.Height = 400;

            UpdateButtonsState();
        }
        public MemberChoiceDialog()
        {
            m_Dialog = new FloatingDialog();
            m_Dialog.Caption = Localization.MemberChoice_Caption + "..."; 

            Grid LayoutRoot = new Grid();
            LayoutRoot.RowDefinitions.Add(new RowDefinition() { });
            LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

            StackPanel buttonsPanel = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right };
            buttonsPanel.Margin = new Thickness(5, 0, 5, 5);

            OkButton = new RanetButton() { Width = 75, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 0, 10, 0) };
            OkButton.Content = Localization.DialogButton_Ok;
            OkButton.Click += new RoutedEventHandler(OkButton_Click);
            buttonsPanel.Children.Add(OkButton);

            CancelButton = new RanetButton() { Width = 75, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 0, 0, 0) };
            CancelButton.Content = Localization.DialogButton_Cancel;
            CancelButton.Click += new RoutedEventHandler(CancelButton_Click);
            buttonsPanel.Children.Add(CancelButton);

            ContentRoot = new Grid();
            ContentRoot.Margin = new Thickness(5);
            LayoutRoot.Children.Add(ContentRoot);
            LayoutRoot.Children.Add(buttonsPanel);
            Grid.SetRow(buttonsPanel, 1);

            m_ChoiceControl = new MemberChoiceControl();
            m_ChoiceControl.ApplySelection += new EventHandler(m_ChoiceControl_ApplySelection);
            //m_ChoiceControl.CancelSelection += new EventHandler(m_ChoiceControl_CancelSelection);
            m_ChoiceControl.MultiSelect = false;
            ContentRoot.Children.Add(m_ChoiceControl);

            m_Dialog.SetContent(LayoutRoot);
            m_Dialog.DialogClosed += new EventHandler<DialogResultArgs>(m_Dialog_DialogClosed);
            m_Dialog.Width = 500;
            m_Dialog.Height = 400;
        }
        public PopUpContainerControl()
        {
            LayoutRoot = new Grid(){Background = new SolidColorBrush(Colors.White) };
            LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition());
            LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto});


            SelectedItemTextBox = new SingleLineTextBox() { IsReadOnly = true, IsTabStop = false };
            SelectedItemTextBox.VerticalAlignment = VerticalAlignment.Stretch;
            SelectedItemTextBox.Margin = new Thickness(0);
            SelectedItemTextBox.Padding = new Thickness(2, 0, 0, 0);
            SelectedItemTextBox.VerticalContentAlignment = VerticalAlignment.Center;
            SelectedItemTextBox.Background = new SolidColorBrush(Colors.White);
            LayoutRoot.Children.Add(SelectedItemTextBox);

            m_SelectButton = new RanetButton();
            LayoutRoot.Children.Add(m_SelectButton);
            m_SelectButton.Margin = new Thickness(-1, 0, 0, 0);
            m_SelectButton.Content = "...";
            //m_SelectButton.Width = 18;
            //m_SelectButton.Height = 18;
//            selectButton.Template = this.Resources["BmButton"] as ControlTemplate;

            m_SelectButton.Click += new RoutedEventHandler(Button_Click);
            Grid.SetColumn(m_SelectButton, 1);

            this.Height = 20;

            resDoubleClickTimer = new Storyboard();
            resDoubleClickTimer.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 250));
            resDoubleClickTimer.Completed += new EventHandler(Storyboard_Completed);
            LayoutRoot.Resources.Add("resDoubleClickTimer", resDoubleClickTimer);

            this.MouseLeftButtonDown += new MouseButtonEventHandler(TreeItemControl_MouseLeftButtonDown);

            this.Content = LayoutRoot;
        }
        public AgPopUpControlBase()
        {
            this.Height = 22;
            this.VerticalAlignment = VerticalAlignment.Top;
            this.Loaded += new RoutedEventHandler(AgPopUpControlBase_Loaded);

            PopUpContainer.BeforePopUp += new EventHandler(OnBeforePopUp);

            PopUpLayoutRoot = new Grid();
            PopUpLayoutRoot.RowDefinitions.Add(new RowDefinition() { });
            PopUpLayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

            StackPanel buttonsPanel = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right };
            buttonsPanel.Margin = new Thickness(5, 0, 5, 5);

            OkButton = new RanetButton() { Width = 75, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 0, 10, 0) };
            OkButton.Content = Localization.DialogButton_Ok;
            OkButton.Click += new RoutedEventHandler(OkButton_Click);
            buttonsPanel.Children.Add(OkButton);

            CancelButton = new RanetButton() { Width = 75, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 0, 0, 0) };
            CancelButton.Content = Localization.DialogButton_Cancel;
            CancelButton.Click += new RoutedEventHandler(CancelButton_Click);
            buttonsPanel.Children.Add(CancelButton);

            ContentRoot = new Grid();
            ContentRoot.Margin = new Thickness(5);
            PopUpLayoutRoot.Children.Add(ContentRoot);
            PopUpLayoutRoot.Children.Add(buttonsPanel);
            Grid.SetRow(buttonsPanel, 1);

            LayoutRoot = new Grid();
            LayoutRoot.Children.Add(PopUpContainer);

            this.Content = LayoutRoot;
        }
        public ModalDialog()
        {
            Dialog = new FloatingDialog();
            Dialog.Caption = String.Empty;

            Grid PopUpLayoutRoot = new Grid();
            PopUpLayoutRoot.RowDefinitions.Add(new RowDefinition() { });
            PopUpLayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

            // Кнопки OK и Cancel
            StackPanel buttonsPanel = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right };
            buttonsPanel.Margin = new Thickness(5, 0, 5, 5);

            OkButton = new RanetButton() { Width = 75, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0) };
            OkButton.Content = Localization.DialogButton_Ok;
            OkButton.Click += new RoutedEventHandler(OkButton_Click);
            buttonsPanel.Children.Add(OkButton);

            CancelButton = new RanetButton() { Width = 75, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(10, 0, 0, 0) };
            CancelButton.Content = Localization.DialogButton_Cancel;
            CancelButton.Click += new RoutedEventHandler(CancelButton_Click);
            buttonsPanel.Children.Add(CancelButton);

            gridContentContainer = new Grid();
            gridContentContainer.Margin = new Thickness(5);

            PopUpLayoutRoot.Children.Add(gridContentContainer);
            PopUpLayoutRoot.Children.Add(buttonsPanel);
            Grid.SetRow(buttonsPanel, 1);

            Dialog.SetContent(PopUpLayoutRoot);
            Dialog.DialogClosed += new EventHandler<DialogResultArgs>(m_Dialog_DialogClosed);
            Dialog.BeforeClosed += new EventHandler<DialogResultArgs>(m_Dialog_BeforeClosed);
            //m_Dialog.Width = 500;
            Dialog.MinWidth = OkButton.Width + CancelButton.Width + 20;
            //m_Dialog.Height = 400;
        }
        public MemberChoiceControl()
        {
            try
            {
                m_Initializing = true;
                Grid LayoutRoot = new Grid();
                LayoutRoot.RowDefinitions.Add(new RowDefinition());
                // Строка для кнопок
                //OK LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
                LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(2, GridUnitType.Star), MinWidth = 50 });
                // Колонка для свойств
                LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { MinWidth = 50 });

                tabControl = new RanetTabControl();
                tabControl.TabCtrl.SelectionChanged += new SelectionChangedEventHandler(TabControl_SelectionChanged);

                membersTab = new TabItem();
                membersTab.Header = Localization.Members;
                membersTab.Style = tabControl.Resources["TabControlOutputItem"] as Style;

                findTab = new TabItem();
                findTab.Header = Localization.Find;
                findTab.Style = tabControl.Resources["TabControlOutputItem"] as Style;

                mdxSetTab = new TabItem();
                mdxSetTab.Header = Localization.MemberChoice_Selected;
                mdxSetTab.Style = tabControl.Resources["TabControlOutputItem"] as Style;

                tabControl.TabCtrl.Items.Add(membersTab);
                tabControl.TabCtrl.Items.Add(findTab);
                tabControl.TabCtrl.Items.Add(mdxSetTab);

                LayoutRoot.Children.Add(tabControl);

                //OK StackPanel buttonsPanel = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right };
                //LayoutRoot.Children.Add(buttonsPanel);
                //Grid.SetRow(buttonsPanel, 1);

                //Border border = new Border() { BorderBrush = new SolidColorBrush(Colors.DarkGray), BorderThickness = new Thickness(1), Padding = new Thickness(5), Background = new SolidColorBrush(Colors.White) };
                //border.Child = LayoutRoot;

                // Растягиваем дерево
                Grid.SetColumnSpan(tabControl, 2);

                // Закладка MEMBERS
                Grid membersTab_LayoutRoot = new Grid();
                membersTab.Content = membersTab_LayoutRoot;
                membersTab_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
                membersTab_LayoutRoot.RowDefinitions.Add(new RowDefinition());

                membersTree = new CustomTree() { BorderBrush = new SolidColorBrush(Colors.DarkGray) };
                membersTree.Margin = new Thickness(0, 3, 0, 0);
                membersTree.SelectedItemChanged += new RoutedPropertyChangedEventHandler<object>(membersTree_SelectedItemChanged);
                membersTab_LayoutRoot.Children.Add(membersTree);
                Grid.SetRow(membersTree, 1);

                GridSplitter splitter_Vert = new GridSplitter();
                splitter_Vert.IsTabStop = false;
                LayoutRoot.Children.Add(splitter_Vert);
                Grid.SetColumn(splitter_Vert, 0);
                Grid.SetRow(splitter_Vert, 0);
                splitter_Vert.Background = new SolidColorBrush(Colors.Transparent);
                splitter_Vert.HorizontalAlignment = HorizontalAlignment.Right;
                splitter_Vert.VerticalAlignment = VerticalAlignment.Stretch;
                splitter_Vert.Width = 3;

                // Свойства элемента
                m_CurrentMemberControl = new PropertiesControl();
                m_CurrentMemberControl.Background = new SolidColorBrush(Color.FromArgb(0x7F, 128, 128, 128));
                m_CurrentMemberControl.PropertiesList.PropertyColumnWidth = new DataGridLength(100);
                m_PropertiesLayoutBorder = new Border() { BorderBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x80, 0x80, 0x80)), BorderThickness = new Thickness(1) };
                m_PropertiesLayoutBorder.Child = m_CurrentMemberControl;
                LayoutRoot.Children.Add(m_PropertiesLayoutBorder);
                Grid.SetRow(m_PropertiesLayoutBorder, 0);
                Grid.SetColumn(m_PropertiesLayoutBorder, 1);

                // Прячем свойства
                m_PropertiesLayoutBorder.Visibility = Visibility.Collapsed;

                StackPanel members_toolBar = new StackPanel();
                members_toolBar.Orientation = Orientation.Horizontal;

                membersTab_LayoutRoot.Children.Add(members_toolBar);
                Grid.SetRow(members_toolBar, 0);
                Grid.SetColumnSpan(members_toolBar, 2);

                RanetToolBarButton Refresh_Button = new RanetToolBarButton();
                Refresh_Button.Margin = new Thickness(0, 0, 0, 0);
                Refresh_Button.Click += new RoutedEventHandler(RefreshButton_Click);
                Refresh_Button.Content = UiHelper.CreateIcon(UriResources.Images.Refresh16);
                ToolTipService.SetToolTip(Refresh_Button, Localization.MemberChoice_Refresh_ToolTip);
                members_toolBar.Children.Add(Refresh_Button);

                Clear_Choice_Button = new RanetToolBarButton();
                Clear_Choice_Button.Click += new RoutedEventHandler(Clear_Choice_Button_Click);
                Clear_Choice_Button.Content = UiHelper.CreateIcon(UriResources.Images.ClearChoice16);
                ToolTipService.SetToolTip(Clear_Choice_Button, Localization.MemberChoice_ClearSelection_ToolTip);
                members_toolBar.Children.Add(Clear_Choice_Button);

                Levels_ComboBox = new ComboBoxEx();
                Levels_ComboBox.Margin = new Thickness(2, 0, 0, 0);
                Levels_ComboBox.Width = 150;
                members_toolBar.Children.Add(Levels_ComboBox);

                //OK buttonsPanel.Margin = new Thickness(0, 5, 0, 0);
                //Grid.SetColumnSpan(buttonsPanel, 2);
                //OkButton = new RanetButton() { Width = 75, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 0, 10, 0) };
                //OkButton.Content = Localization.DialogButton_Ok;
                //OkButton.Height = 22;
                //OkButton.Click += new RoutedEventHandler(OkButton_Click);
                //buttonsPanel.Children.Add(OkButton);
                //CancelButton = new RanetButton() { Width = 75, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 0, 0, 0) };
                //CancelButton.Content = Localization.DialogButton_Cancel;
                //CancelButton.Height = 22;
                //CancelButton.Click += new RoutedEventHandler(CancelButton_Click);
                //buttonsPanel.Children.Add(CancelButton);

                membersTree.Special_MouseDoubleClick += new EventHandler<CustomEventArgs<CustomTreeNode>>(node_SpecialNodeExpanded);

                // Закладка ПОИСК
                Grid findTab_LayoutRoot = new Grid();
                findTab.Content = findTab_LayoutRoot;

                findTab_LayoutRoot.RowDefinitions.Add(new RowDefinition());
                findTab_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
                findTab_LayoutRoot.RowDefinitions.Add(new RowDefinition());
                findTab_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(22) });

                filterBuilder = new FilterBuilderControl();
                filterBuilder.ApplyFilter += new EventHandler(filterBuilder_ApplyFilter);
                findTab_LayoutRoot.Children.Add(filterBuilder);

                RanetButton RunSearch_Button = new RanetButton();
                RunSearch_Button.Height = 22;
                RunSearch_Button.Width = 75;
                RunSearch_Button.Margin = new Thickness(2, 5, 0, 0);
                RunSearch_Button.Content = Localization.Find;
                RunSearch_Button.HorizontalAlignment = HorizontalAlignment.Right;
                RunSearch_Button.Click += new RoutedEventHandler(RunSearch_Button_Click);

                findTab_LayoutRoot.Children.Add(RunSearch_Button);
                Grid.SetRow(RunSearch_Button, 1);

                // Дерево с результатом поиска
                findResultTree = new CustomTree() { BorderBrush = new SolidColorBrush(Colors.DarkGray) };
                findResultTree.SelectedItemChanged += new RoutedPropertyChangedEventHandler<object>(tree_SelectedItemChanged);
                findResultTree.Margin = new Thickness(0, 5, 0, 0);
                findTab_LayoutRoot.Children.Add(findResultTree);
                Grid.SetRow(findResultTree, 2);

                // Количество найденных элементов
                Grid find_buttons_panel = new Grid();
                find_buttons_panel.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
                find_buttons_panel.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });

                TextBlock m_Find_Results = new TextBlock() { Text = Localization.MemberChoice_MembersFound };
                m_Find_Results.VerticalAlignment = VerticalAlignment.Center;
                find_buttons_panel.Children.Add(m_Find_Results);

                m_Find_Count = new TextBlock() { Text = "0" };
                m_Find_Count.VerticalAlignment = VerticalAlignment.Center;
                find_buttons_panel.Children.Add(m_Find_Count);
                Grid.SetColumn(m_Find_Count, 1);

                findTab_LayoutRoot.Children.Add(find_buttons_panel);
                Grid.SetRow(find_buttons_panel, 3);

                // Закладка ВЫБРАННЫЕ
                Grid mdxSetTab_LayoutRoot = new Grid();
                mdxSetTab.Content = mdxSetTab_LayoutRoot;
                mdxSetTab_LayoutRoot.RowDefinitions.Add(new RowDefinition());
                mdxSetTab_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(22) });
                mdxSetTab_LayoutRoot.RowDefinitions.Add(new RowDefinition());

                selectedList = new CustomTree() { BorderBrush = new SolidColorBrush(Colors.DarkGray) };
                selectedList.SelectedItemChanged += new RoutedPropertyChangedEventHandler<object>(tree_SelectedItemChanged);
                mdxSetTab_LayoutRoot.Children.Add(selectedList);

                // Количество выбранных элементов
                Grid selected_buttons_panel = new Grid();
                selected_buttons_panel.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
                selected_buttons_panel.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });

                TextBlock m_Selected_Results = new TextBlock() { Text = Localization.MemberChoice_MembersSelected };
                m_Selected_Results.Margin = new Thickness(0, 5, 0, 5);
                m_Selected_Results.VerticalAlignment = VerticalAlignment.Center;
                selected_buttons_panel.Children.Add(m_Selected_Results);

                m_Selected_Count = new TextBlock() { Text = "0" };
                m_Selected_Count.VerticalAlignment = VerticalAlignment.Center;
                m_Selected_Count.Margin = new Thickness(0, 5, 0, 5);
                selected_buttons_panel.Children.Add(m_Selected_Count);
                Grid.SetColumn(m_Selected_Count, 1);

                mdxSetTab_LayoutRoot.Children.Add(selected_buttons_panel);
                Grid.SetRow(selected_buttons_panel, 1);

                mdxSetTextBox = new SimpleTextBox() { AcceptsReturn = true, TextWrapping = TextWrapping.Wrap, IsReadOnly = true };
                mdxSetTextBox.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
                mdxSetTextBox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
                mdxSetTextBox.Margin = new Thickness(0, 0, 0, 0);
                mdxSetTextBox.BorderBrush = new SolidColorBrush(Colors.Black);
                mdxSetTab_LayoutRoot.Children.Add(mdxSetTextBox);
                Grid.SetRow(mdxSetTextBox, 2);

                SelectedItemChanged_Story = new Storyboard();
                SelectedItemChanged_Story.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
                SelectedItemChanged_Story.Completed += new EventHandler(SelectedItemChanged_Story_Completed);
                membersTab_LayoutRoot.Resources.Add("SelectedItemChanged_Story", SelectedItemChanged_Story);

                // Кнопка для отображения свойств элемента
                m_ShowMemberPropertiesButton = new RanetToggleButton();

                TabToolBar toolbar = tabControl.ToolBar;
                if (toolbar != null)
                {
                    ToolTipService.SetToolTip(m_ShowMemberPropertiesButton, Localization.MemberChoice_ShowMemberProperties_ToolTip);
                    m_ShowMemberPropertiesButton.Click += new RoutedEventHandler(SowMemberPropertiesButton_Click);
                    m_ShowMemberPropertiesButton.Content = UiHelper.CreateIcon(UriResources.Images.MemberProperty16);
                    toolbar.Stack.Children.Add(m_ShowMemberPropertiesButton);
                }

                this.Content = LayoutRoot;
            }
            finally {
                m_Initializing = false;
            }
        }
        public ValueDeliveryControl()
        {
            Grid LayoutRoot = new Grid();
            LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            LayoutRoot.RowDefinitions.Add(new RowDefinition());

            // Грид для свойств ячейки
            Grid Row0_LayoutRoot = new Grid();
            Row0_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition());
            Row0_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            Row0_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            Row0_LayoutRoot.RowDefinitions.Add(new RowDefinition());
            
            Border Row0_Border = new Border() { BorderBrush = new SolidColorBrush(Colors.DarkGray) };
            Row0_Border.BorderThickness = new Thickness(1);
            Row0_Border.Padding = new Thickness(5);
            Row0_Border.Child = Row0_LayoutRoot;

            LayoutRoot.Children.Add(Row0_Border);

            TextBlock cellSettings = new TextBlock();
            cellSettings.Margin = new Thickness(0, 0, 0, 0);
            cellSettings.Text = Localization.ValueDeliveryControl_DeliveredCellSettings;
            Row0_LayoutRoot.Children.Add(cellSettings);

            // Тапл ячейки
            m_Tupple = new CellTupleControl();
            m_Tupple.SelectedItemChanged += new EventHandler<TupleItemArgs>(m_Tupple_SelectedItemChanged);
            m_Tupple.Margin = new Thickness(0, 5, 0, 0);
            m_Tupple.Height = 170;
            Row0_LayoutRoot.Children.Add(m_Tupple);
            Grid.SetRow(m_Tupple, 1);

            Grid DeliveryInfo_LayoutRoot = new Grid();
            DeliveryInfo_LayoutRoot.Margin = new Thickness(10, 0, 20, 0);
            DeliveryInfo_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition());
            DeliveryInfo_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto, MinWidth = 50 });
            DeliveryInfo_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            DeliveryInfo_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            DeliveryInfo_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            DeliveryInfo_LayoutRoot.RowDefinitions.Add(new RowDefinition());

            // Начальное значение
            TextBlock Label_ValueToDelivery = new TextBlock() { Text = Localization.ValueDeliveryDialog_ValueToDelivery, Margin = new Thickness(5) };
            DeliveryInfo_LayoutRoot.Children.Add(Label_ValueToDelivery);
            m_ValueToDelivery = new TextBlock() { Text = m_OriginalValue.ToString(), Margin = new Thickness(5) };
            DeliveryInfo_LayoutRoot.Children.Add(m_ValueToDelivery);
            Grid.SetColumn(m_ValueToDelivery, 1);
            
            // Распределено
            TextBlock Label_Delivered = new TextBlock() { Text = Localization.ValueDeliveryDialog_Delivered, Margin = new Thickness(5) };
            DeliveryInfo_LayoutRoot.Children.Add(Label_Delivered);
            Grid.SetRow(Label_Delivered, 1);
            m_Delivered = new TextBlock() { Margin = new Thickness(5) };
            DeliveryInfo_LayoutRoot.Children.Add(m_Delivered);
            Grid.SetColumn(m_Delivered, 1);
            Grid.SetRow(m_Delivered, 1);
            
            // Остаток к распределению
            TextBlock Label_RestToDelivery = new TextBlock() { Text = Localization.ValueDeliveryDialog_RestToDelivery, Margin = new Thickness(5) };
            DeliveryInfo_LayoutRoot.Children.Add(Label_RestToDelivery);
            Grid.SetRow(Label_RestToDelivery, 2);
            m_RestToDelivery = new TextBlock() { Margin = new Thickness(5) };
            DeliveryInfo_LayoutRoot.Children.Add(m_RestToDelivery);
            Grid.SetColumn(m_RestToDelivery, 1);
            Grid.SetRow(m_RestToDelivery, 2);

            RefreshDeliveredInfo();

            Row0_LayoutRoot.Children.Add(DeliveryInfo_LayoutRoot);
            Grid.SetColumn(DeliveryInfo_LayoutRoot, 1);
            Grid.SetRow(DeliveryInfo_LayoutRoot, 1);

            // Выбор по каким элементам разноска
            Grid DeliveryMode_LayoutRoot = new Grid();
            DeliveryMode_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition());
            DeliveryMode_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto});
            DeliveryMode_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            DeliveryMode_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            DeliveryMode_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

            Border Row1_Border = new Border() { BorderBrush = new SolidColorBrush(Colors.DarkGray) };
            Row1_Border.BorderThickness = new Thickness(1);
            Row1_Border.Margin = new Thickness(0, 5, 0, 5);
            Row1_Border.Padding = new Thickness(5);
            Row1_Border.Child = DeliveryMode_LayoutRoot;

            LayoutRoot.Children.Add(Row1_Border);
            Grid.SetRow(Row1_Border, 1);

            // Заголовок
            TextBlock delivTo = new TextBlock();
            delivTo.Text = Localization.ValueDeliveryControl_DeliveryTo;
            DeliveryMode_LayoutRoot.Children.Add(delivTo);

            // Выбор элементов для разноски (доступен только для режима "выбранные из списка")
            m_MembersChoice = new MemberChoicePopUp();
            m_MembersChoice.IsEnabled = false;
            DeliveryMode_LayoutRoot.Children.Add(m_MembersChoice);
            Grid.SetRow(m_MembersChoice, 2);

            // Тип разноски
            m_DevileryModeCombo = new ComboBoxEx();
            m_DevileryModeCombo.Margin = new Thickness(0, 5, 0, 5);
            ItemControlBase ctrl;
            ctrl = new ItemControlBase(false);
            ctrl.Text = Localization.ValueDeliveryControl_ChildrenMembers;
            m_DevileryModeCombo.Combo.Items.Add(ctrl);
            ctrl = new ItemControlBase(false);
            ctrl.Text = Localization.ValueDeliveryControl_SiblingsMembers;
            m_DevileryModeCombo.Combo.Items.Add(ctrl);
            ctrl = new ItemControlBase(false);
            ctrl.Text = Localization.ValueDeliveryControl_SelectedMembers;
            m_DevileryModeCombo.Combo.Items.Add(ctrl);
            m_DevileryModeCombo.SelectionChanged += new SelectionChangedEventHandler(m_DevileryModeCombo_SelectionChanged);
            m_DevileryModeCombo.Combo.SelectedIndex = 0;
            DeliveryMode_LayoutRoot.Children.Add(m_DevileryModeCombo);
            Grid.SetRow(m_DevileryModeCombo, 1);
            
            // Кнопка Применить
            RanetButton ApplyButton = new RanetButton();
            ApplyButton.Content = Localization.Apply;
            ApplyButton.Margin = new Thickness(5, 5, 0, 5);
            ApplyButton.Click += new RoutedEventHandler(ApplyButton_Click);
            DeliveryMode_LayoutRoot.Children.Add(ApplyButton);
            Grid.SetColumn(ApplyButton, 1);
            Grid.SetRow(ApplyButton, 1);

            // Элементы по которым возможна разноска
            Grid Row2_LayoutRoot = new Grid();
            Row2_LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            Row2_LayoutRoot.RowDefinitions.Add(new RowDefinition());

            TextBlock membersToDelivery = new TextBlock();
            membersToDelivery.Margin = new Thickness(0, 0, 0, 0);
            membersToDelivery.Text = Localization.ValueDeliveryControl_MembersToDelivery;
            Row2_LayoutRoot.Children.Add(membersToDelivery);

            m_MembersGrid = new RanetDataGrid();
            m_MembersGrid.Margin = new Thickness(0, 5, 0, 0);
            m_MembersGrid.AlternatingRowBackground = new SolidColorBrush(Colors.White);
            m_MembersGrid.RowBackground = new SolidColorBrush(Colors.White);
            m_MembersGrid.AutoGenerateColumns = false;
            m_MembersGrid.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            m_MembersGrid.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            m_MembersGrid.RowHeight = 22;

            DataGridTextColumn memberColumn = new DataGridTextColumn();
            memberColumn.Header = Localization.ValueDeliveryControl_Member;
            memberColumn.Binding = new System.Windows.Data.Binding("Caption");
            memberColumn.IsReadOnly = true;
            m_MembersGrid.Columns.Add(memberColumn);

            DataGridTextColumn originalValueColumn = new DataGridTextColumn();
            originalValueColumn.Header = Localization.ValueDeliveryControl_OriginalValue;
            originalValueColumn.Binding = new System.Windows.Data.Binding("OriginalValue");
            originalValueColumn.IsReadOnly = true;
            m_MembersGrid.Columns.Add(originalValueColumn);

            DataGridTextColumn deliveredValueColumn = new DataGridTextColumn();
            deliveredValueColumn.Header = Localization.ValueDeliveryControl_Delivered;
            deliveredValueColumn.Binding = new System.Windows.Data.Binding("DeliveredValue");
            m_MembersGrid.Columns.Add(deliveredValueColumn);

            DataGridTextColumn newValueColumn = new DataGridTextColumn();
            newValueColumn.Header = Localization.ValueDeliveryControl_NewValue;
            newValueColumn.Binding = new System.Windows.Data.Binding("NewValue");
            newValueColumn.IsReadOnly = true;
            m_MembersGrid.Columns.Add(newValueColumn);

            Row2_LayoutRoot.Children.Add(m_MembersGrid);
            Grid.SetRow(m_MembersGrid, 1);

            Border Row2_Border = new Border() { BorderBrush = new SolidColorBrush(Colors.DarkGray) };
            Row2_Border.BorderThickness = new Thickness(1);
            Row2_Border.Padding = new Thickness(5);
            Row2_Border.Child = Row2_LayoutRoot;

            LayoutRoot.Children.Add(Row2_Border);
            Grid.SetRow(Row2_Border, 2);

            this.Content = LayoutRoot;
            m_MembersGrid.CellEditEnded += new EventHandler<DataGridCellEditEndedEventArgs>(m_MembersGrid_CellEditEnded);
        }
        public XYNavigator()
        {
            LayoutRoot = new Grid();
            LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            LayoutRoot.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

            LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });

            m_UpButton = new RanetButton() { Width = 18, Height = 18 };
            m_UpButton.Content = UiHelper.CreateIcon(UriResources.Images.Up16);
            m_UpButton.Click += new RoutedEventHandler(m_UpButton_Click);

            m_DownButton = new RanetButton() { Width = 18, Height = 18 };
            m_DownButton.Content = UiHelper.CreateIcon(UriResources.Images.Down16);
            m_DownButton.Click += new RoutedEventHandler(m_DownButton_Click);

            m_LeftButton = new RanetButton() { Width = 18, Height = 18 };
            m_LeftButton.Content = UiHelper.CreateIcon(UriResources.Images.Left16);
            m_LeftButton.Click += new RoutedEventHandler(m_LeftButton_Click);

            m_RightButton = new RanetButton() { Width = 18, Height = 18 };
            m_RightButton.Content = UiHelper.CreateIcon(UriResources.Images.Right16);
            m_RightButton.Click += new RoutedEventHandler(m_RightButton_Click);

            RefreshButtonsAlignment();
            this.Content = LayoutRoot;
        }