public void AddModel(IShellPresentationModel model) { ApplicationBar applicationBar = new ApplicationBar(); applicationBar.DataContext = model; applicationBar.ActionMenuItemSelected += ActionMenuItemSelectedEventHandler; applicationBar.StartMenuItemExecuted += StartMenuItemExecutedEventHandler; NavigationPane pane = new NavigationPane(); pane.Title = model.Module.Title; pane.Content = applicationBar; pane.Name = model.Module.Id; pane.Tag = model.Module; if (model.Module.Icon != null) { Rect rect = new Rect(0, 0, 24, 24); DrawingVisual drawingVisual = new DrawingVisual(); using (DrawingContext drawingContext = drawingVisual.RenderOpen()) { drawingContext.DrawImage(model.Module.Icon, rect); } RenderTargetBitmap bitmap = new RenderTargetBitmap((int)rect.Width, (int)rect.Height, 96, 96, PixelFormats.Default); bitmap.Render(drawingVisual); pane.ImageSourceLarge = bitmap; pane.ImageSourceSmall = model.Module.Icon; } navigationBar.Items.Add(pane); }
private void button1_Click(object sender, EventArgs e) { //if (string.IsNullOrWhiteSpace(txtTaiKhoan.Text)) //{ // MessageBox.Show("Chưa nhập tài khoản", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); //} //else if (string.IsNullOrWhiteSpace(txtMatKhau.Text)) //{ // MessageBox.Show("Chưa nhập mật khẩu", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); //} //else //{ // DataTable dtLogin = DataController.ExecTable("select manv, tentaikhoan, matkhau from nhanvien"); // foreach (DataRow row in dtLogin.Rows) // { // if (txtTaiKhoan.Text == row["tentaikhoan"].ToString() && txtMatKhau.Text == row["matkhau"].ToString()) // { // LoginUser.manv = int.Parse(row["manv"].ToString()); // Form main = new MainForm(); // main.Show(); // this.Hide(); // return; // } // } // MessageBox.Show("Nhập sai tài khoản hoặc mật khẩu", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); //} NavigationPane pane = new NavigationPane(); pane.Activate(); }
public void Handle(PaneVisibilityChangedEvent args) { if (args.IsVisible == false) { return; } switch (args.Pane) { case Pane.Navigation: NavigationPane.Show(); break; case Pane.Filter: FilterPane.Show(); break; case Pane.Layout: LayoutPane.Show(); break; case Pane.Legend: LegendPane.Show(); break; case Pane.Property: PropertyPane.Show(); break; } }
private void CleanSubItems() { bool itemsAreHiddenItems = MenuType == ConfiguretMenuItemType.HiddenItems; bool itemExists, itemIsHidden, itemIsExcluded; object[] keys = new object[_subItems.Count]; _subItems.Keys.CopyTo(keys, 0); int firstItemHidden = _navigationPane.GetFirstItemIndex(NavigationPaneItemDisplayType.Undefined); for (int j = keys.Length - 1; j > -1; j--) { object key = keys[j]; object item = key is NavigationPaneItem ? key : _navigationPane.ItemContainerGenerator.ItemFromContainer(key as DependencyObject); itemExists = _navigationPane.Items.Contains(item); itemIsExcluded = NavigationPane.GetIsItemExcluded(key as DependencyObject); itemIsHidden = _navigationPane.Items.IndexOf(item) >= firstItemHidden && firstItemHidden != -1; if (!itemExists || ((!itemIsHidden || itemIsExcluded) && itemsAreHiddenItems)) { if (itemsAreHiddenItems) { _contextMenu.Items.Remove(_subItems[key]); } else if (MenuType == ConfiguretMenuItemType.AddRemove) { Items.Remove(_subItems[key]); } _subItems.Remove(key); } } }
public NavigationPaneOptions(NavigationPane navigationPane) { this.navigationPane = navigationPane; CoerceValue(CanReorderProperty); Items = new ObservableCollection <NavigationPaneOptionsData>(); ResetItems(); this.InitializeComponent(); DataContext = Items; }
protected override void OnVisualParentChanged(DependencyObject oldParent) { base.OnVisualParentChanged(oldParent); _navigationPane = TryFindNavigationPane() as NavigationPane; if (MenuType != ConfiguretMenuItemType.MenuItem) { SetValues(); } }
internal static bool LoadState(FrameworkElement control, Stream stream) { States states = GetCurrentStates(stream); string pId = control.Name; StatesControl ctrl = states.GetControl(pId); if (ctrl != null) { MinimizeHelper minimizeHelper = ((IMinimizeHelped)control).ResizeHelper; control.Visibility = ctrl.Visibility; control.Width = ctrl.Width; minimizeHelper.IsMinimized = ctrl.Minimized; minimizeHelper.ExpandedWidth = ctrl.ExpandedWidth; minimizeHelper.ExpandedDelta = ctrl.ExpandedDelta; minimizeHelper.ResetMinizedSize(); if (control is NavigationPane) { NavigationPane pane = control as NavigationPane; pane.LargeItems = ctrl.Items.LargeItems; IEnumerable <NavigationPaneItem> items = pane.Items.OfType <NavigationPaneItem>(); // if Linq were a girl, I should absolutely marry her var sorted = from data in ( from item in items join sItem in ctrl.Items.Items on item.Name equals sItem.Identifier into itemStates from itemState in itemStates.DefaultIfEmpty() select new { Index = itemState == null ? NavigationPanePanel.GetAbosluteIndex(item) : itemState.Order - 0.5, Exluded = itemState == null ? false : itemState.Excluded, Item = item } ) orderby data.Index select data; List <NavigationPaneItem> orderdItems = new List <NavigationPaneItem>(); foreach (var item in sorted) { NavigationPane.SetIsItemExcluded(item.Item, item.Exluded); orderdItems.Add(item.Item); } pane.Items.Clear(); foreach (NavigationPaneItem item in orderdItems) { pane.Items.Add(item); } } return(true); } return(false); }
private void NavigationBarSelectionChangedEventHandler(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (e.OriginalSource == navigationBar && e.AddedItems.Count > 0 && WorkItem.RootWorkItem.Items.FindByType <ShellHyperlink>().Count == 0) //Looks at shellhyperlink in workitem to prevent dialog specified in activation uri from opening before the module is fully loaded at application startup. { NavigationPane pane = e.AddedItems[0] as NavigationPane; if (pane != null && pane.IsVisible) { Presenter.ActivateModule(pane.Tag as IShellModule); } } }
void navigationPane1_StateChanged(object sender, StateChangedEventArgs e) { NavigationPane navPane = sender as NavigationPane; if (e.State == NavigationPaneState.Collapsed) { navPane.PageProperties.ShowMode = ItemShowMode.Image; navPane.LayoutChanged(); Size newSize = (navPane as INavigationPane).RegularMinSize; navPane.Width = newSize.Width - NavigationPane.StickyWidth; } }
private void InitializeGroupView() { // // FPaletteGroupBar // _paletteGroupBar = new NavigationPane(); _paletteGroupBar.AllowDrop = true; _paletteGroupBar.BackColor = SystemColors.Control; //FPaletteGroupBar.BorderStyle = BorderStyle.FixedSingle; _paletteGroupBar.Dock = DockStyle.Fill; _paletteGroupBar.Location = new Point(0, 24); _paletteGroupBar.Name = "FPaletteGroupBar"; //FPaletteGroupBar.SelectedItem = 0; _paletteGroupBar.Size = new Size(163, 163); _paletteGroupBar.TabIndex = 1; // // FPointerGroupView // _pointerGroupView = new ListView { BorderStyle = BorderStyle.None, //ButtonView = true, View = View.List, Dock = DockStyle.Top }; _pointerGroupView.Items.AddRange(new[] { new ListViewItem("Pointer", 0) }); //FPointerGroupView.IntegratedScrolling = true; //FPointerGroupView.ItemYSpacing = 2; _pointerGroupView.LargeImageList = null; _pointerGroupView.Location = new Point(0, 0); _pointerGroupView.Name = "FPointerGroupView"; //FPointerGroupView.SelectedItem = 0; _pointerGroupView.Items[0].Selected = true; _pointerGroupView.MultiSelect = false; _pointerGroupView.Size = new Size(163, 24); _pointerGroupView.SmallImageList = FPointerImageList; //FPointerGroupView.SmallImageView = true; _pointerGroupView.TabIndex = 0; _pointerGroupView.Text = "groupView2"; //FPointerGroupView.GroupViewItemSelected += FPointerGroupView_GroupViewItemSelected; _pointerGroupView.ItemSelectionChanged += FPointerGroupView_ItemSelectionChanged; Controls.Add(_paletteGroupBar); Controls.Add(_pointerGroupView); }
public static void SaveState(FrameworkElement control, Stream stream) { if (string.IsNullOrEmpty(control.Name)) { throw new UniqueIdentierNotSet(); } States states = GetCurrentStates(stream); XmlSerializer s = new XmlSerializer(typeof(States)); string pId = control.Name; StatesControl ctrl = states.GetControl(pId, true); //we should use the MinizeHelper to get the correct size if the control io minimized MinimizeHelper minimizeHelper = ((IMinimizeHelped)control).ResizeHelper; ctrl.ExpandedWidth = minimizeHelper.ExpandedWidth; ctrl.ExpandedDelta = minimizeHelper.ExpandedDelta; ctrl.ActualWidth = control.ActualWidth; ctrl.Width = control.Width; ctrl.Minimized = minimizeHelper.IsMinimized; ctrl.Visibility = control.Visibility; if (control is NavigationPane) { NavigationPane pane = control as NavigationPane; if (ctrl.Items == null) { ctrl.Items = new StatesControlItems(); } ctrl.Items.LargeItems = pane.LargeItems; ctrl.Items.Items.Clear(); for (int j = 0; j < pane.Items.Count; j++) { NavigationPaneItem item = (NavigationPaneItem)pane.Items[j]; if (!string.IsNullOrEmpty(item.Name)) { ctrl.Items.Items.Add(new StatesControlItemsItem(item.Name, NavigationPane.GetIsItemExcluded(item), j)); } } } s.Serialize(stream, states); }
public void LoadSettings(object target, object settings) { if (settings != null) { NavigationBarLayoutSerializer serializer = new NavigationBarLayoutSerializer(); try { serializer.LoadFromString((string)settings); serializer.ApplyTo((NavigationBar)target); } catch (SerializationException) { } } else { if (target is NavigationBar) { NavigationBar navigationBar = (NavigationBar)target; bool changed = true; while (changed) { changed = false; int lastIndex = -1; for (int index = 0; index < navigationBar.Items.Count; index++) { int orderIndex = ((Imi.SupplyChain.UX.Infrastructure.IShellModule)((NavigationPane)navigationBar.Items[index]).Tag).OrderIndex; if (orderIndex < lastIndex) { NavigationPane previousItem = (NavigationPane)navigationBar.Items[index - 1]; NavigationPane currentItem = (NavigationPane)navigationBar.Items[index]; navigationBar.Items.RemoveAt(index); navigationBar.Items.Insert(index - 1, currentItem); changed = true; } lastIndex = orderIndex; } } } } }
private void TestAddButton(NavigationPane navPane, string t) { ButtonItem b = new DevComponents.DotNetBar.ButtonItem(); navPane.Items.Add(b); b.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.ImageAndText; //b.Image = ((System.Drawing.Image)(resources.GetObject("buttonItem2.Image"))); b.ImageIndex = 1; //b.Name = "b"; // b.OptionGroup = "navBar"; b.Style = DevComponents.DotNetBar.eDotNetBarStyle.Office2003; b.Text = t; // b.Tooltip = t; MakePanelToGoWithButton(navPane, b, null); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="sbContainer">The control that contains the sidebar control.</param> /// <param name="ibContainer">The control that contains the information bar.</param> /// <param name="mediator">XCore message mediator through which messages are sent /// for tab and tab item clicks.</param> /// ------------------------------------------------------------------------------------ public void Initialize(Control sbContainer, Control ibContainer, Mediator mediator) { if (sbContainer == null) { return; } m_mediator = mediator; m_navPane = new NavigationPane(); m_navPane.Dock = DockStyle.Fill; //Setup context menu to allow switching between large and small icon mode. SetupSideBarsContextMenu(); SetupInfoBar(ibContainer); m_navPane.AllowDrop = false; m_navPane.AutoSizeButtonImage = true; m_navPane.ImageSizeSummaryLine = new Size(16, 16); m_navPane.ConfigureAddRemoveVisible = false; m_navPane.ConfigureShowHideVisible = false; m_navPane.ConfigureNavOptionsVisible = false; m_navPane.Load += new EventHandler(m_navPane_Load); m_navPane.PanelChanging += new PanelChangingEventHandler(m_navPane_PanelChanging); m_navPane.TitlePanel.Dock = DockStyle.Top; m_navPane.TitlePanel.Font = Font.FromLogFont(Win32Api.NonClientMetrics.lfCaptionFont); m_navPane.TitlePanel.Size = new Size(1, ibContainer == null ? 28 : ibContainer.Height); m_navPane.TitlePanel.Style.Border = eBorderType.SingleLine; m_navPane.TitlePanel.Style.MarginLeft = 4; m_navPane.TitlePanel.Style.Alignment = StringAlignment.Near; m_navPane.TitlePanel.MouseEnter += new EventHandler(TitlePanel_MouseEnter); if (m_dnbMngr.IsThemeActive) { m_navPane.TitlePanel.ColorSchemeStyle = eDotNetBarStyle.Office2003; } else { m_navPane.TitlePanel.Paint += new PaintEventHandler(PaintNonThemedPanel); } sbContainer.Controls.Add(m_navPane); }
void ButtonsPanel_ButtonClick(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e) { NavigationPaneButtonsPanel panel = sender as NavigationPaneButtonsPanel; NavigationPane navPane = panel.Owner as NavigationPane; if (navPane.State == NavigationPaneState.Collapsed) { navPane.State = NavigationPaneState.Default; return; } if (navPane.PageProperties.ShowMode == ItemShowMode.Image) { navPane.PageProperties.ShowMode = ItemShowMode.ImageAndText; } else { navPane.PageProperties.ShowMode = ItemShowMode.Image; } }
protected void MakePanelToGoWithButton(NavigationPane np, ButtonItem button, ListPropertyChoice choice) { m_suspendEvents = true; NavigationPanePanel p = new DevComponents.DotNetBar.NavigationPanePanel(); p.Dock = System.Windows.Forms.DockStyle.Fill; p.Location = new System.Drawing.Point(0, 24); p.ParentItem = button; p.Style.Alignment = System.Drawing.StringAlignment.Center; p.Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground; p.Style.BackColor2.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground2; p.Style.BackgroundImagePosition = DevComponents.DotNetBar.eBackgroundImagePosition.Tile; p.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine; p.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; p.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemText; p.Style.GradientAngle = 90; p.Style.WordWrap = true; p.StyleMouseDown.Alignment = System.Drawing.StringAlignment.Center; p.StyleMouseDown.WordWrap = true; p.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center; p.StyleMouseOver.WordWrap = true; p.TabIndex = 3; // Object maker =m_mediator.PropertyTable.GetValue("PanelMaker"); // if (maker == null) // { // p.Text = "You must provide a PanelMaker in the property table to create panels"; // p.Name = "navigationPanePanel2"; // } // else // { AddControlsToPanel(choice, p); // } //p.VisibleChanged +=new EventHandler(OnPanelVisibleChanged); np.Controls.Add(p); p.Layout += new LayoutEventHandler(OnPanelLayout); m_suspendEvents = false; }
private static void OnIsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { NavigationPaneItem item = d as NavigationPaneItem; if ((bool)e.NewValue) { NavigationPane nav = item.navigationPane; // item.Parent as NavigationPane; if (nav != null) { NavigationPaneItem selItem = (nav.SelectedItem is NavigationPaneItem ? nav.SelectedItem : nav.ItemContainerGenerator.ContainerFromItem(nav.SelectedItem)) as NavigationPaneItem; if (selItem != null && selItem != item) { (selItem as NavigationPaneItem).IsSelected = false; } } item.ChangeSelected(true); } else { item.ChangeSelected(false); } }
protected override Size MeasureOverride(Size availableSize) { Size desiredSize = new Size(); UIElementCollection children = InternalChildren; IItemContainerGenerator generator = ItemContainerGenerator; int itemsCount = 0; if (generator != null) { int StartItemIndex = navigationPane.GetFirstItemIndex(DisplayType); if (StartItemIndex > -1) { int maxItems = DisplayType == NavigationPaneItemDisplayType.Large ? navigationPane.LargeItems : int.MaxValue; GeneratorPosition startPos = new GeneratorPosition(-1, StartItemIndex + 1); using (generator.StartAt(startPos, GeneratorDirection.Forward, true)) { bool sizeExceeded = false; bool newlyRealized; UIElement child = null; // temp fix for {Disconnected Item} // needs more inspecting and documentation to fix it correctly !! // but this for now seems to work... strange items present ?? // remove them, NOW !!!!! //for (int j = children.Count - 1; j > -1; j--) //{ //UIElement item = children[j]; //object o = navigationPane.ItemContainerGenerator.ItemFromContainer(item); //if (o == DependencyProperty.UnsetValue) // RemoveInternalChild(item); //} while (!sizeExceeded && (itemsCount < maxItems) && (child = generator.GenerateNext(out newlyRealized) as UIElement) != null) { bool isExcluded = NavigationPane.GetIsItemExcluded(child); if (!isExcluded) { if (newlyRealized || !children.Contains(child)) { int absoluteIndex = StartItemIndex + itemsCount; int index = GetInsertIndex(absoluteIndex); if (absoluteIndex < 9 && navigationPane.ItemsKeyAuto) { NavigationPaneItem f = child as NavigationPaneItem; { Window w = Window.GetWindow(child); if (w != null) { KeyBinding binding = f.keyBinding; if (binding != null) { w.InputBindings.Remove(binding); } f.keyBinding = new KeyBinding(NavigationPane.SelectItemCommand, Key.D1 + absoluteIndex, navigationPane.ItemsKeyModifiers); f.keyBinding.CommandParameter = child; f.keyBinding.CommandTarget = navigationPane; w.InputBindings.Add(f.keyBinding); if (f != null) { f.Gesture = (f.keyBinding.Gesture as KeyGesture).GetDisplayStringForCulture(CultureInfo.CurrentCulture); } } } } SetActivePanel(child, this); SetAbosluteIndex(child, absoluteIndex); SetItemDisplayType(child, DisplayType); if (newlyRealized) { generator.PrepareItemContainer(child); } InsertInternalChild(index, child); } #region measurament algoritm Size childSize = new Size(); if (Orientation == Orientation.Vertical) { childSize = new Size(availableSize.Width, double.PositiveInfinity); } else { childSize = new Size(double.PositiveInfinity, availableSize.Height); } child.Measure(childSize); if (Orientation == Orientation.Vertical) { sizeExceeded = desiredSize.Height + child.DesiredSize.Height > availableSize.Height; if (!sizeExceeded) { desiredSize.Width = Math.Max(desiredSize.Width, child.DesiredSize.Width); desiredSize.Height += child.DesiredSize.Height; } } else { sizeExceeded = desiredSize.Width + child.DesiredSize.Width > availableSize.Width; if (!sizeExceeded) { desiredSize.Width += child.DesiredSize.Width; desiredSize.Height = Math.Max(desiredSize.Height, child.DesiredSize.Height); } } #endregion if (!sizeExceeded) { itemsCount++; } } else { RemoveInternalChild(child); } } } CleanUpItems(StartItemIndex, itemsCount); } } if (DisplayType == NavigationPaneItemDisplayType.Small) { navigationPane.SmallItems = itemsCount; } return(desiredSize); }
private void CheckHiddenItems() { if (_contextMenu == null) { return; } int startIndex = _contextMenu.Items.IndexOf(this); int index = startIndex - _subItems.Count; for (int firstHidden = _navigationPane.GetFirstItemIndex(NavigationPaneItemDisplayType.Undefined); firstHidden != -1 && firstHidden < _navigationPane.Items.Count; firstHidden++) { NavigationPaneItem item = _navigationPane.Items[firstHidden] as NavigationPaneItem; if (item != null && !NavigationPane.GetIsItemExcluded(item)) { index++; if (!_subItems.Contains(item)) { MenuItem menuItem = MenuItemFromNavigationPaneItem(item, true); _subItems.Add(item, menuItem); _contextMenu.Items.Insert(index, menuItem); } } } CleanSubItems(); bool addSeparator = (_subItems.Count > 0); if (addSeparator && Separator == ConfigureMenuSeparator.Top || Separator == ConfigureMenuSeparator.Both) { if (_separatorTop == null) { _separatorTop = new Separator(); } if (!_contextMenu.Items.Contains(_separatorTop)) { _contextMenu.Items.Insert(startIndex, _separatorTop); } } else if (_contextMenu.Items.Contains(_separatorTop)) { _contextMenu.Items.Remove(_separatorTop); } if (addSeparator && Separator == ConfigureMenuSeparator.Bottom || Separator == ConfigureMenuSeparator.Both) { if (_separatorBottom == null) { _separatorBottom = new Separator(); } if (!_contextMenu.Items.Contains(_separatorBottom)) { _contextMenu.Items.Insert(index + 1, _separatorBottom); } } else if (_contextMenu.Items.Contains(_separatorBottom)) { _contextMenu.Items.Remove(_separatorBottom); } }
private void ResetItems() { Items.Clear(); for (int j = 0; j < navigationPane.Items.Count; j++) { NavigationPaneItem item = navigationPane.Items[j] is NavigationPaneItem ? navigationPane.Items[j] as NavigationPaneItem: navigationPane.ItemContainerGenerator.ContainerFromIndex(j) as NavigationPaneItem; if (item != null) { Items.Add(new NavigationPaneOptionsData(item, XamlHelper.CloneUsingXaml(item.Header, true), !NavigationPane.GetIsItemExcluded(item))); } } }
public CustomNavigationButton(NavigationPane navigationPane) : base(navigationPane.SelectedPage) { paneCore = navigationPane; }