/// <summary> /// Set new position in collection /// </summary> /// <param name="tButton">NavigateBarButton object</param> /// <param name="tNewIndex">New index in collection</param> public void SetChildIndex(NavigateBarButton tButton, int tNewIndex) { if (tButton == null) { return; } int oldIndex = this.List.IndexOf(tButton); // Eğer yeri daha önceli bir konuma alınmışsa if (oldIndex > tNewIndex) { for (int i = oldIndex; i >= (tNewIndex + 1); i--) { this.List[i] = this.List[i - 1]; } } else if (oldIndex < tNewIndex) // Eğer bulunduğu posizyondan sonraki bir posizyona alınmışsa { for (int i = oldIndex + 1; i <= tNewIndex; i++) { this.List[i - 1] = this.List[i]; } } this.List[tNewIndex] = tButton; }
/// <summary> /// Insert a new button in collection /// </summary> /// <param name="tIndex">Index no</param> /// <param name="tButton">NavigateBarButton object</param> public virtual void Insert(int tIndex, NavigateBarButton tButton) { if (!this.Contains(tButton)) { this.List.Insert(tIndex, tButton); } }
public NavigateBarButtonEventArgs(NavigateBarButton tNavigateBarButton) { if (tNavigateBarButton == null) throw new NullReferenceException("Cannot null tNavigateBarButton"); navigateBarButton = tNavigateBarButton; }
/// <summary> /// Remove exist a button from collection /// </summary> /// <param name="tButton">NavigateBarButton object</param> public virtual void Remove(NavigateBarButton tButton) { if (this.Contains(tButton)) { this.List.Remove(tButton); } }
/// <summary> /// Check change in checked list on click OK button /// </summary> bool CheckChanges() { bool isChange = false; for (int i = 0; i < collectionOrder.Count; i++) { NavigateBarButton nvb = null; CheckedListItem cli = (lstButtons.Items[i] as CheckedListItem); collectionOrder.TryGetValue(i, out nvb); if (nvb != null) { // Liste içerisindeki sırası değişti mi ? // Is change button order if (cli.Index != i) { isChange = true; break; } else { // Check durumu değişti mi? // Is change checked state if (nvb.IsDisplayed != cli.Checked) { isChange = true; break; } } } } return(isChange || isReset); }
/// <summary> /// Add a new button in collection /// </summary> /// <param name="tButton">NavigateBarButton object</param> public virtual void Add(NavigateBarButton tButton) { // Only once if (!this.Contains(tButton)) { this.List.Add(tButton); } }
public NavigateBarButtonEventArgs(NavigateBarButton tNavigateBarButton) { if (tNavigateBarButton == null) { throw new NullReferenceException("Cannot null tNavigateBarButton"); } navigateBarButton = tNavigateBarButton; }
/// <summary> /// Remove exist a button from collection using key value /// </summary> /// <param name="tKey"></param> public virtual void RemoveByKey(string tKey) { NavigateBarButton nvb = this.FindByKey(tKey); if (nvb != null) { this.Remove(nvb); } }
public NavigateBarOverFlowPanelButton(NavigateBarButton tNavigateBarButton) { navigateBarButton = tNavigateBarButton; this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.UserPaint, true); InitOverFlowButton(); }
void InitNavigateBarOptions() { // Text btnCancel.Text = Properties.Resources.TEXT_BUTTON_CANCEL; btnMoveDown.Text = Properties.Resources.TEXT_BUTTON_MOVE_DOWN; btnMoveUp.Text = Properties.Resources.TEXT_BUTTON_MOVE_UP; btnReset.Text = Properties.Resources.TEXT_BUTTON_RESET; btnOK.Text = Properties.Resources.TEXT_BUTTON_OK; Text = Properties.Resources.TEXT_MENU_OPTIONS.Replace("&", "").Replace("...", ""); lblOrderDescription.Text = Properties.Resources.TEXT_LABEL_ORDER_DESCRIPTION; // Orjinal durumlarını dictionary ekle // Save orjinal state for (int i = 0; i < navigateBar.NavigateBarButtons.Count; i++) { NavigateBarButton nvb = navigateBar.NavigateBarButtons[i]; collectionOrder.Add(i, nvb); } // Listeyi yükle // Load checked list LoadList(); // Listedeki eleman sayısına göre buttonları ayarla // Set enabled state for list button count if (lstButtons.Items.Count < 0) { btnMoveDown.Enabled = false; btnMoveUp.Enabled = false; btnOK.Enabled = false; btnReset.Enabled = false; } // lstButtons.SelectionMode = SelectionMode.One; lstButtons.ItemCheck += new ItemCheckEventHandler(CheckList_ItemCheck); this.KeyPreview = true; this.KeyPress += delegate(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Escape) { this.Close(); } }; }
public ButtonContextMenu(NavigateBarButton tButton) { button = tButton; mnHideItem = new ToolStripMenuItem(); mnHideItem.Text = Properties.Resources.TEXT_BUTTON_HIDE + " " + tButton.Caption; mnHideItem.Click += new EventHandler(mnHideItem_Click); mnMenuOption = new ToolStripMenuItem(); mnMenuOption.Text = Properties.Resources.TEXT_MENU_OPTIONS; mnMenuOption.Click += new EventHandler(mnMenuOption_Click); Items.Add(mnHideItem); Items.Add(mnMenuOption); this.Opening += new CancelEventHandler(ButtonContextMenu_Opening); }
protected override void OnKeyUp(KeyEventArgs e) { if (e.KeyData == Keys.Enter || e.KeyData == Keys.Space) { if (!this.IsArrowButton) { e.Handled = true; isSelected = true; this.PaintingType = PaintType.Selected; NavigateBarButton.PerformClick(); } } else { base.OnKeyUp(e); } }
public NavigateBarOverFlowPanelMenuItem(NavigateBarButton tNavigateBarButton, bool tCheckMenu) { navigateBarButton = tNavigateBarButton; if (navigateBarButton == null) return; this.Text = navigateBarButton.Caption; this.Image = navigateBarButton.Image; if (tCheckMenu) { this.CheckOnClick = true; this.CheckState = tNavigateBarButton.IsDisplayed ? CheckState.Checked : CheckState.Unchecked; } }
public NavigateBarOverFlowPanelMenuItem(NavigateBarButton tNavigateBarButton, bool tCheckMenu) { navigateBarButton = tNavigateBarButton; if (navigateBarButton == null) { return; } this.Text = navigateBarButton.Caption; this.Image = navigateBarButton.Image; if (tCheckMenu) { this.CheckOnClick = true; this.CheckState = tNavigateBarButton.IsDisplayed ? CheckState.Checked : CheckState.Unchecked; } }
/// <summary> /// Build and show context menu on arrow button click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ArrowButton_MouseClick(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) { return; } mnContextMenu.RightToLeft = this.NavigateBar.IsUseRTLforMenus ? this.NavigateBar.RightToLeft : RightToLeft.No; mnContextMenu.Renderer = navigateBar.ContextMenuRenderer; // Sabit Elemanlar // Constant items this.BuildContextMenuItems(); // Değişken Elemanlar // Changeable items bool isAddedSeparator = false; for (int i = 0; i < navigateBar.NavigateBarButtons.Count; i++) { NavigateBarButton nvbButton = navigateBar.NavigateBarButtons[i]; if (!nvbButton.OverFlowPanelButton.Visible && nvbButton.IsDisplayed) { // Add Separator if (!isAddedSeparator) { isAddedSeparator = true; mnContextMenu.Items.Add(new ToolStripSeparator()); } // mnContextMenu.Items.Add(nvbButton.ContextMenuItem); } } // OK tıklandığında okun yanında context menü açılması sağlanıyor // Click arrow button show context menu near arrow button mnContextMenu.Show(this, this.Left + (this.NavigateBar.RightToLeft == RightToLeft.Yes ? 0 : this.Width), panelArrowBtn.Top + this.Height / 2); }
/// <summary> /// Click RESET button. ReLoad list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnReset_Click(object sender, EventArgs e) { collectionOrder.Clear(); int i = 0; foreach (KeyValuePair <string, int> key in navigateBar.buttonOrder) { NavigateBarButton button = navigateBar.NavigateBarButtons.FindByKey(key.Key); if (button != null) { collectionOrder.Add(i, button); i++; } } isReset = true; LoadList(); }
protected override void OnMouseClick(MouseEventArgs e) { base.OnMouseClick(e); toolTip.RemoveAll(); // Only left click if (e.Button == MouseButtons.Left && !this.IsArrowButton) // Sadece sol click ile button seçilebilmeli { this.IsSelected = true; this.PaintingType = PaintType.Selected; NavigateBarButton.PerformClick(); } else { if (!this.IsArrowButton) { Point p = this.PointToScreen(new Point(this.Location.X - this.Left + this.Width, this.Location.Y)); NavigateBarButton.ButtonMenu.Show(p); } } }
/// <summary> /// Search button using key value /// </summary> /// <param name="tKey">NavigateBarButton key value</param> /// <returns></returns> public NavigateBarButton FindByKey(string tKey) { NavigateBarButton retButton = null; if (string.IsNullOrEmpty(tKey)) { return(retButton); } foreach (NavigateBarButton nvb in this.List) { if (!string.IsNullOrEmpty(nvb.Key) && nvb.Key.Equals(tKey)) { retButton = nvb; break; } } return(retButton); }
/// <summary> /// Eklenen butonlara göre overflowpanel için contextmenuyu oluşturur /// </summary> void BuildContextMenuItems() { mnContextMenu.Items.Clear(); mnAddRemoveButton.DropDownItems.Clear(); mnContextMenu.Items.Add(mnShowMoreButton); mnContextMenu.Items.Add(mnShowFewerButton); mnContextMenu.Items.Add(mnMenuOptions); mnContextMenu.Items.Add(mnAddRemoveButton); // NavigateBarButton görünümleri değiştiren ContextMenu oluşturuluyor // Building context menu navigatebarbutton in collection foreach (NavigateBarButton nvbButton in navigateBar.NavigateBarButtons) { // Her zaman gösterilecek // If always show skip if (nvbButton.IsAlwaysDisplayed) { continue; } NavigateBarOverFlowPanelMenuItem ofpmi = new NavigateBarOverFlowPanelMenuItem(nvbButton, true); ofpmi.Click += delegate(object sender, EventArgs e) { // Seçilen Button Panel içerisindek kaldırılır yada eklenilir // Show or Hide NavigatebarButton in panel if (sender is NavigateBarOverFlowPanelMenuItem) { NavigateBarButton nvb = (sender as NavigateBarOverFlowPanelMenuItem).NavigateBarButton; nvb.IsDisplayed = !nvb.IsDisplayed; } }; mnAddRemoveButton.DropDownItems.Add(ofpmi); } }
/// <summary> /// Insert a new button in collection /// </summary> /// <param name="tIndex">Index no</param> /// <param name="tButton">NavigateBarButton object</param> public virtual void Insert(int tIndex, NavigateBarButton tButton) { if (!this.Contains(tButton)) this.List.Insert(tIndex, tButton); }
/// <summary> /// Remove exist a button from collection /// </summary> /// <param name="tButton">NavigateBarButton object</param> public virtual void Remove(NavigateBarButton tButton) { if (this.Contains(tButton)) this.List.Remove(tButton); }
void InitNavigateBarOverFlowPanel() { // Control this.Dock = DockStyle.Fill; this.Height = navigateBar.OverFlowPanelHeight; this.MinimumSize = new Size(NavigateBar.OVER_FLOW_BUTTON_WIDTH, 20); #region Context Menu Items mnContextMenu = new ContextMenuStrip(); mnContextMenu.Opening += delegate(object sender, CancelEventArgs e) { foreach (ToolStripItem tsi in mnContextMenu.Items) tsi.ForeColor = SystemColors.MenuText; }; // Menü kapatıldığında okun clickini kaldır // Closed context menu remove selected state on arrow button mnContextMenu.Closed += delegate(object sender, ToolStripDropDownClosedEventArgs e) { panelArrowBtn.IsSelected = false; Refresh(); }; // Show More Button menu item mnShowMoreButton = new NavigateBarOverFlowPanelMenuItem(null, false); mnShowMoreButton.Text = Properties.Resources.TEXT_SHOW_MORE_BUTTONS; mnShowMoreButton.Image = Properties.Resources.ArrowUp; mnShowMoreButton.Click += delegate(object sender, EventArgs e) { NavigateBar.MoveButtons(MoveType.MoveUp); }; // Show Fewer Button menu item mnShowFewerButton = new NavigateBarOverFlowPanelMenuItem(null, false); mnShowFewerButton.Text = Properties.Resources.TEXT_SHOW_FEWER_BUTTONS; mnShowFewerButton.Image = Properties.Resources.ArrowDown; mnShowFewerButton.Click += delegate(object sender, EventArgs e) { NavigateBar.MoveButtons(MoveType.MoveDown); }; // Seçenek // Menu Options menu item mnMenuOptions = new NavigateBarOverFlowPanelMenuItem(null, false); mnMenuOptions.Text = Properties.Resources.TEXT_MENU_OPTIONS; mnMenuOptions.Click += delegate(object sender, EventArgs e) { NavigateBar.RunMenuOptionsDialog(); }; // Ekle / Kaldır // Add or Remove Button menu item mnAddRemoveButton = new NavigateBarOverFlowPanelMenuItem(null, false); mnAddRemoveButton.Text = Properties.Resources.TEXT_ADD_OR_REMOVE_BUTTON; mnAddRemoveButton.DropDownOpening += delegate(object sender, EventArgs e) { foreach (NavigateBarOverFlowPanelMenuItem item in mnAddRemoveButton.DropDownItems) item.Checked = item.NavigateBarButton.IsDisplayed; }; #endregion #region Arrow button for ContextMenu panelArrowNavBtn = new NavigateBarButton(Properties.Resources.TEXT_CONFIGURE_BUTTONS); panelArrowNavBtn.NavigateBar = NavigateBar; panelArrowNavBtn.ToolTipText = Properties.Resources.TEXT_CONFIGURE_BUTTONS; panelArrowBtn = new NavigateBarOverFlowPanelButton(panelArrowNavBtn); this.SetPanelArrowPosition(); panelArrowBtn.IsSelected = false; panelArrowBtn.Visible = true; panelArrowBtn.IsArrowButton = true; panelArrowBtn.MouseClick += new MouseEventHandler(ArrowButton_MouseClick); this.Controls.Add(panelArrowBtn); #endregion this.ResizeRedraw = true; // }
/// <summary> /// Add buttons in collection /// </summary> /// <param name="tButtons"></param> public virtual void AddRange(NavigateBarButton[] tButtons) { foreach (NavigateBarButton nvb in tButtons) this.Add(nvb); }
/// <summary> /// Set new position in collection /// </summary> /// <param name="tButton">NavigateBarButton object</param> /// <param name="tNewIndex">New index in collection</param> public void SetChildIndex(NavigateBarButton tButton, int tNewIndex) { if (tButton == null) return; int oldIndex = this.List.IndexOf(tButton); // Eğer yeri daha önceli bir konuma alınmışsa if (oldIndex > tNewIndex) { for (int i = oldIndex; i >= (tNewIndex + 1); i--) this.List[i] = this.List[i - 1]; } else if (oldIndex < tNewIndex) // Eğer bulunduğu posizyondan sonraki bir posizyona alınmışsa { for (int i = oldIndex + 1; i <= tNewIndex; i++) this.List[i - 1] = this.List[i]; } this.List[tNewIndex] = tButton; }
void InitNavigateBarOverFlowPanel() { // Control this.Dock = DockStyle.Fill; this.Height = navigateBar.OverFlowPanelHeight; this.MinimumSize = new Size(NavigateBar.OVER_FLOW_BUTTON_WIDTH, 20); #region Context Menu Items mnContextMenu = new ContextMenuStrip(); mnContextMenu.Opening += delegate(object sender, CancelEventArgs e) { foreach (ToolStripItem tsi in mnContextMenu.Items) { tsi.ForeColor = SystemColors.MenuText; } }; // Menü kapatıldığında okun clickini kaldır // Closed context menu remove selected state on arrow button mnContextMenu.Closed += delegate(object sender, ToolStripDropDownClosedEventArgs e) { panelArrowBtn.IsSelected = false; Refresh(); }; // Show More Button menu item mnShowMoreButton = new NavigateBarOverFlowPanelMenuItem(null, false); mnShowMoreButton.Text = Properties.Resources.TEXT_SHOW_MORE_BUTTONS; mnShowMoreButton.Image = Properties.Resources.ArrowUp; mnShowMoreButton.Click += delegate(object sender, EventArgs e) { NavigateBar.MoveButtons(MoveType.MoveUp); }; // Show Fewer Button menu item mnShowFewerButton = new NavigateBarOverFlowPanelMenuItem(null, false); mnShowFewerButton.Text = Properties.Resources.TEXT_SHOW_FEWER_BUTTONS; mnShowFewerButton.Image = Properties.Resources.ArrowDown; mnShowFewerButton.Click += delegate(object sender, EventArgs e) { NavigateBar.MoveButtons(MoveType.MoveDown); }; // Seçenek // Menu Options menu item mnMenuOptions = new NavigateBarOverFlowPanelMenuItem(null, false); mnMenuOptions.Text = Properties.Resources.TEXT_MENU_OPTIONS; mnMenuOptions.Click += delegate(object sender, EventArgs e) { NavigateBar.RunMenuOptionsDialog(); }; // Ekle / Kaldır // Add or Remove Button menu item mnAddRemoveButton = new NavigateBarOverFlowPanelMenuItem(null, false); mnAddRemoveButton.Text = Properties.Resources.TEXT_ADD_OR_REMOVE_BUTTON; mnAddRemoveButton.DropDownOpening += delegate(object sender, EventArgs e) { foreach (NavigateBarOverFlowPanelMenuItem item in mnAddRemoveButton.DropDownItems) { item.Checked = item.NavigateBarButton.IsDisplayed; } }; #endregion #region Arrow button for ContextMenu panelArrowNavBtn = new NavigateBarButton(Properties.Resources.TEXT_CONFIGURE_BUTTONS); panelArrowNavBtn.NavigateBar = NavigateBar; panelArrowNavBtn.ToolTipText = Properties.Resources.TEXT_CONFIGURE_BUTTONS; panelArrowBtn = new NavigateBarOverFlowPanelButton(panelArrowNavBtn); this.SetPanelArrowPosition(); panelArrowBtn.IsSelected = false; panelArrowBtn.Visible = true; panelArrowBtn.IsArrowButton = true; panelArrowBtn.MouseClick += new MouseEventHandler(ArrowButton_MouseClick); this.Controls.Add(panelArrowBtn); #endregion this.ResizeRedraw = true; // }
public CheckedListItem(NavigateBarButton tNavigateBarButton) { navigateBarButton = tNavigateBarButton; isChecked = navigateBarButton.IsDisplayed; }
/// <summary> /// Check collection /// </summary> /// <param name="tButton">NavigateBarButton object</param> /// <returns>bool</returns> public virtual bool Contains(NavigateBarButton tButton) { return this.List.Contains(tButton); }
/// <summary> /// Get index no in collection /// </summary> /// <param name="tButton">NavigateBarButton object</param> /// <returns>int</returns> public virtual int IndexOf(NavigateBarButton tButton) { return this.List.IndexOf(tButton); }
/// <summary> /// Get index no in collection /// </summary> /// <param name="tButton">NavigateBarButton object</param> /// <returns>int</returns> public virtual int IndexOf(NavigateBarButton tButton) { return(this.List.IndexOf(tButton)); }
/// <summary> /// Add a new button in collection /// </summary> /// <param name="tButton">NavigateBarButton object</param> public virtual void Add(NavigateBarButton tButton) { // Only once if (!this.Contains(tButton)) this.List.Add(tButton); }
internal void SetCaptionText(NavigateBarButton tButton) { if (tButton != null) { navigateBarCaption.Caption = tButton.Caption; navigateBarCaption.Image = tButton.IsShowCaptionImage ? tButton.Image : null; navigateBarCaptionDesc.Caption = tButton.CaptionDescription; navigateBarCaption.Visible = tButton.IsShowCaption; navigateBarCaptionDesc.Visible = tButton.IsShowCaptionDescription; } else { navigateBarCaption.Caption = ""; navigateBarCaption.Image = null; navigateBarCaptionDesc.Caption = ""; navigateBarCaption.Visible = true; navigateBarCaptionDesc.Visible = false; } navigateBarCaption.Invalidate(); navigateBarCaptionDesc.Invalidate(); }
/// <summary> /// If changed IsDisplayed state NavigateBarButton /// </summary> /// <param name="tOldValue"></param> /// <param name="tNewValue"></param> void NavigateBarButton_DisplayChanged(bool tOldValue, bool tNewValue) { displayedButtonCount = this.GetVisibleButtonCount(VisibleType.Visible); lastDisplayedButtonCount = displayedButtonCount; bool existsDisplay = false; // Tüm butonlar eğer görünmüyorsa Control görünüm alanını ve // overflow kontrol alanını temizle // selectedButton null olarak ata // If all buttons is not displayed then clear overflowpanel and set null selectedbutton foreach (NavigateBarButton nvb in this.NavigateBarButtons) { if (nvb.IsDisplayed) { existsDisplay = true; break; } } // Eğer seçili button IsDisplayed değilse olan ilk tabı seç // If selected new button not isdisplayed then select possible first button if (existsDisplay && selectedButton != null) { if (!this.selectedButton.IsDisplayed) { foreach (NavigateBarButton nvb in this.NavigateBarButtons) { if (nvb.IsDisplayed) { this.SelectedButton = nvb; break; } } } } else { SetControlForNavigateBarButton(null); displayedButtonCount = this.GetVisibleButtonCount(VisibleType.Visible); navigateBarCaption.Caption = ""; navigateBarCaptionDesc.Caption = ""; selectedButton = null; } // NavigateBarı yenile // Refresh items on navigatebar ChangeSplitterPosition(); ReDisplayNavigateBarButtons(); // OverFlowPaneli yenile // Refresh items on overflowpanel ReFreshOverFlowPanel(false); ReSizeControlPanel(); }
/// <summary> /// Check collection /// </summary> /// <param name="tButton">NavigateBarButton object</param> /// <returns>bool</returns> public virtual bool Contains(NavigateBarButton tButton) { return(this.List.Contains(tButton)); }
/// <summary> /// Change position in panel and collection /// </summary> /// <param name="tButton">NavigateBarButton object in collection</param> /// <param name="tNewPosition">New postion in panel</param> public void ChangeButtonPosition(NavigateBarButton tButton, int tNewPosition) { // Check parameters if (!this.NavigateBarButtons.Contains(tButton)) return; if (tNewPosition < 0 || tNewPosition > navigateBarButtons.Count - 1) return; // Set new position this.NavigateBarButtons.SetChildIndex(tButton, tNewPosition); this.Controls.SetChildIndex(tButton, tNewPosition + 3); // Caption Panel + Rel. Cont. Panel + Splitter // ReDisplay Panel and overflowpanel this.ReDisplayNavigateBarButtons(); this.ReFreshOverFlowPanel(false); }
public NavigateBarButtonCancelEventArgs(NavigateBarButton tSelected, NavigateBarButton tPreviousSelected) { selected = tSelected; previousSelected = tPreviousSelected; this.Cancel = false; }
/// <summary> /// Save settings in XML file /// </summary> public bool SaveSettingsToXmlFile() { bool isSaved = true; if (string.IsNullOrEmpty(settingsFileName)) { errorMessage = "Setting file name is null or empty"; return(false); } if (!navigateBar.SaveAndRestoreSettings) { if (File.Exists(settingsFileName)) { File.Delete(settingsFileName); } return(false); } try { if (navigateBar.NavigateBarButtons.Count < 0) { return(false); } int dispCount = navigateBar.NavigateBarButtons.GetDisplayedItemCount(); FileInfo fInfo = new FileInfo(settingsFileName); if (!Directory.Exists(fInfo.DirectoryName)) { Directory.CreateDirectory(fInfo.DirectoryName); } XmlTextWriter xtw = new XmlTextWriter(settingsFileName, Encoding.UTF8); xtw.Formatting = Formatting.Indented; xtw.WriteStartDocument(true); // Comment xtw.WriteComment("Outlook 2003 Style Navigation Pane Settings"); xtw.WriteComment("Do not manual change this file"); // Navigatebar panel info #region NavigateBar xtw.WriteStartElement("NavigationPaneSettings"); xtw.WriteAttributeString("DiplayedButtonCount", dispCount.ToString()); xtw.WriteAttributeString("ButtonHeight", navigateBar.NavigateBarButtonHeight.ToString()); xtw.WriteAttributeString("PaneWidth", navigateBar.Width.ToString()); xtw.WriteAttributeString("IsShowCollapseButton", navigateBar.IsShowCollapseButton.ToString()); xtw.WriteAttributeString("IsCollapsible", navigateBar.IsCollapsible.ToString()); xtw.WriteAttributeString("OverFlowPanelHeight", navigateBar.OverFlowPanelHeight.ToString()); #endregion // Color Table info #region Color Table xtw.WriteStartElement("ColorTable"); Type t = navigateBar.NavigateBarColorTable.GetType(); foreach (PropertyInfo pi in t.GetProperties(BindingFlags.Public | BindingFlags.Instance)) { //if (pi.MemberType != MemberTypes.Property) continue; object obj = pi.GetValue(navigateBar.NavigateBarColorTable, null); if (obj == null) { continue; } string strval = ""; if (pi.PropertyType == typeof(Color)) { strval = ((Color)obj).ToArgb().ToString(); } if (pi.PropertyType == typeof(bool)) { strval = ((bool)obj).ToString(); } if (pi.PropertyType == typeof(float)) { strval = ((float)obj).ToString(); } if (pi.PropertyType == typeof(ContextMenuArrowStyle)) { strval = ((ContextMenuArrowStyle)obj).ToString(); } xtw.WriteElementString(pi.Name, strval); } xtw.WriteEndElement(); #endregion // Buttons info #region Buttons for (int i = 0; i < navigateBar.NavigateBarButtons.Count; i++) { NavigateBarButton nvb = navigateBar.NavigateBarButtons[i]; // If null or empty key value skip this button if (!string.IsNullOrEmpty(nvb.Key)) // Key boş bırakılan buttonlar xml içerisine kayıt edilmiyor { xtw.WriteStartElement(nvb.Key.Replace(" ", "")); xtw.WriteAttributeString("Enabled", nvb.Enabled.ToString()); xtw.WriteAttributeString("Display", nvb.IsDisplayed.ToString()); xtw.WriteAttributeString("Visible", nvb.Visible.ToString()); xtw.WriteAttributeString("Selected", nvb.IsSelected.ToString()); xtw.WriteAttributeString("OrderNo", i.ToString()); xtw.WriteEndElement(); } } #endregion xtw.WriteEndElement(); // NavigationPaneSettings xtw.Flush(); xtw.Close(); } catch (Exception e) { errorMessage = e.Message; isSaved = false; } return(isSaved); }
/// <summary> /// If button cannot displayed NavigateBar panel then display on this panel /// </summary> public void ReDisplayOverFlowButtons(bool tCheck) { if (tCheck && lastItemCount == navigateBar.OverFlowItemCount) { return; } this.SuspendLayout(); // OverFlowPanel üzerine simgeleri sırasına göre ekle // Eğer simgelerin toplam uzunluğu panelden fazla ise ContextMenu üzerine ekle // Panel içerisine kaç adet button sığıyor // Add button on overflowpanel looking order // calculate how many button displayable on panel // If cannot display button on overflowpanel then show on contextmenu int addedBtnCount = 0; int displayableBtnCount = (this.Width - NavigateBar.OVER_FLOW_BUTTON_WIDTH - 4) / NavigateBar.OVER_FLOW_BUTTON_WIDTH; displayableBtnCount = (displayableBtnCount > navigateBar.OverFlowItemCount ? navigateBar.OverFlowItemCount : displayableBtnCount); for (int i = 0; i < navigateBar.NavigateBarButtons.Count; i++) { NavigateBarButton nvbButton = navigateBar.NavigateBarButtons[i]; NavigateBarOverFlowPanelButton overFlowPanelButton = nvbButton.OverFlowPanelButton; overFlowPanelButton.Visible = true; // Eğer button panel içerisinde gösterliyorsa ve daha önce overflowpanel // içerisinde ise overlofwpanel buttonu kaldır if (nvbButton.Visible || !nvbButton.IsDisplayed) { if (this.Controls.Contains(overFlowPanelButton)) { this.Controls.Remove(overFlowPanelButton); } continue; } if (overFlowPanelButton.IsOnOverFlowPanel && overFlowPanelButton.NavigateBarButton.IsDisplayed) // Eğer panel üzerindeki button ise // If is display { if (addedBtnCount < displayableBtnCount) // Tüm buttonlar sığıyor // all buttons can visible { if (this.NavigateBar.RightToLeft == RightToLeft.Yes) { overFlowPanelButton.Left = Math.Abs(displayableBtnCount - addedBtnCount) * NavigateBar.OVER_FLOW_BUTTON_WIDTH; // Normal sıralı dizmek için } else { overFlowPanelButton.Left = this.Width - Math.Abs(addedBtnCount - displayableBtnCount - 1 /* Arrow Button*/) * NavigateBar.OVER_FLOW_BUTTON_WIDTH; // Tersten dizmek için } if (!this.Controls.Contains(overFlowPanelButton)) { this.Controls.Add(overFlowPanelButton); } addedBtnCount++; } else { overFlowPanelButton.Visible = false; } } else { overFlowPanelButton.Visible = false; } } lastItemCount = navigateBar.OverFlowItemCount; // this.ResumeLayout(false); }
void NavigateBarButton_Selected(NavigateBarButtonEventArgs e) { // Zaten seçili ise // If already selected return if (this.SelectedButton != null && this.SelectedButton.Equals(e.NavigateBarButton)) return; // Cancel Selected Button NavigateBarButton previousSelected = this.SelectedButton; NavigateBarButtonCancelEventArgs cancelArgs = new NavigateBarButtonCancelEventArgs(e.NavigateBarButton, previousSelected); if (this.OnNavigateBarButtonSelecting != null) // Run Selecting Event this.OnNavigateBarButtonSelecting(cancelArgs); if (cancelArgs.Cancel) // Check Cancel state { e.NavigateBarButton.IsSelected = false; this.SelectedButton = previousSelected; previousSelected = null; return; } // Control içerisindeki tüm butonların IsSelected ayarla // set IsSelected state for all buttons in collection foreach (NavigateBarButton nvb in this.NavigateBarButtons) nvb.IsSelected = nvb.Equals(e.NavigateBarButton); // Seçili NavigateBarButtonun özelliklerini aktar // Set new caption and image info for selected button this.SetCaptionText(e.NavigateBarButton); // Select Button selectedButton = e.NavigateBarButton; // Seçilen NavigateBarButton için Controlü göster // display releated control for selected button this.SetControlForNavigateBarButton(e.NavigateBarButton.RelatedControl); // If set true IsShowOnButtonSelect and not displayed screen then show collapse screen if (this.IsCollapseScreenShowOnButtonSelect && !collapsibleScreen.IsShowWindow) ShowOverScreen(); // Trigger Event if (OnNavigateBarButtonSelected != null) OnNavigateBarButtonSelected(e.NavigateBarButton); }