/// <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); } }
/// <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> /// 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> /// 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); } }
/// <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 NavigateBarButtonEventArgs(NavigateBarButton tNavigateBarButton) { if (tNavigateBarButton == null) { throw new NullReferenceException("Cannot null tNavigateBarButton"); } navigateBarButton = tNavigateBarButton; }
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 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; } }
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 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); }
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(); }
/// <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); }
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> /// 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); } }
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> /// 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); }
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> /// Any button selected /// </summary> /// <param name="tNavigateBarButton"></param> void outlookNavigatePane_OnNavigateBarButtonSelected(NavigateBarButton tNavigateBarButton) { if (outlookNavigatePane == null || nbRemoteControl == null) return; //nbRemoteControl.nudPosition.Value = outlookNavigatePane.NavigateBarButtons.IndexOf(tNavigateBarButton); if (outlookNavigatePane.SelectedButton != null) this.Text = outlookNavigatePane.SelectedButton.Caption; }
/// <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> /// 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 NavigateBarButtonCancelEventArgs(NavigateBarButton tSelected, NavigateBarButton tPreviousSelected) { selected = tSelected; previousSelected = tPreviousSelected; this.Cancel = false; }
/// <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(); }
void NavigateBarButton_Selected(NavigateBarButtonEventArgs e) { // Zaten seçili ise // If already selected return if (this.SelectedButton != null && this.SelectedButton.Equals(e.NavigateBarButton)) return; // Button seçim işlemini kontrol et // 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); }
/// <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); }
/// <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> /// Add buttons in collection /// </summary> /// <param name="tButtons"></param> public virtual void AddRange(NavigateBarButton[] tButtons) { foreach (NavigateBarButton nvb in tButtons) this.Add(nvb); }
/// <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> /// Check collection /// </summary> /// <param name="tButton">NavigateBarButton object</param> /// <returns>bool</returns> public virtual bool Contains(NavigateBarButton tButton) { return(this.List.Contains(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); }
/// <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 CheckedListItem(NavigateBarButton tNavigateBarButton) { navigateBarButton = tNavigateBarButton; isChecked = navigateBarButton.IsDisplayed; }
/// <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); }
public void InitNavigateBar() { // For automatically save (Save %APPDATA%<exe filename> folder ) //outlookNavigatePane = new NavigateBar(); //outlookNavigatePane.SaveAndRestoreSettings = true; // For custom save outlookNavigatePane = new NavigateBar(Environment.CurrentDirectory + @"\NavigateBarSettings.xml"); outlookNavigatePane.Dock = DockStyle.Left; outlookNavigatePane.IsShowCollapsibleScreen = true; outlookNavigatePane.CollapsedScreenWidth = 150; // For all buttons // Optional outlookNavigatePane.CollapsibleWidth = 32; outlookNavigatePane.OnNavigateBarDisplayedButtonCountChanged += new NavigateBar.OnNavigateBarDisplayedButtonCountChangedEventHandler(NavigationPane_OnNavigateBarDisplayedButtonCountChanged); outlookNavigatePane.OnNavigateBarButtonSelected += new NavigateBar.OnNavigateBarButtonEventHandler(outlookNavigatePane_OnNavigateBarButtonSelected); outlookNavigatePane.OnNavigateBarButtonSelecting += new NavigateBar.OnNavigateBarButtonSelectingEventHandler(outlookNavigatePane_OnNavigateBarButtonSelecting); outlookNavigatePane.OnNavigateBarColorChanged += new EventHandler(outlookNavigatePane_OnNavigateBarColorChanged); outlookNavigatePane.HandleCreated += new EventHandler(outlookNavigatePane_HandleCreated); outlookNavigatePane.RightToLeftChanged += new EventHandler(outlookNavigatePane_RightToLeftChanged); outlookNavigatePane.Width = 150; #region Optional features //outlookNavigatePane.RelatedControl = new MailTree(); // If Button.RelatedControl is empty then display this control //outlookNavigatePane.NavigateBarDisplayedButtonCount = 5; // Max display 5 button in panel //outlookNavigatePane.AlwaysUseSystemColors = true; #endregion #region NavigateBar Buttons nvbMail = new NavigateBarButton(); nvbMail.RelatedControl = new MailTree(); nvbMail.Caption = "Mail"; nvbMail.CaptionDescription = "Mail Folders"; nvbMail.Image = Properties.Resources.Mail24; nvbMail.Enabled = true; nvbMail.Key = "MAIL"; nvbMail.IsShowCaptionImage = false; nvbMail.OnNavigateBarButtonSelected += new NavigateBarButton.OnNavigateBarButtonSelectedEventHandler(nvbMail_OnNavigateBarButtonSelected); Calendar clndr = new Calendar(); clndr.BackColor = Color.Red; nvbCalendar = new NavigateBarButton(clndr); nvbCalendar.Caption = "Calendar"; nvbCalendar.IsShowCaption = true; nvbCalendar.IsShowCaptionDescription = false; nvbCalendar.Image = Properties.Resources.Calendar24; //nvbCalendar.Font = new Font("Tahoma", 12, FontStyle.Italic | FontStyle.Bold); nvbCalendar.ForeColor = Color.Red; // move on ColorTable nvbCalendar.Key = "CALENDAR"; nvbCalendar.IsShowCaptionImage = false; nvbCalendar.CollapsedScreenWidth = 195; nvbCalendar.IsShowCollapseScreenCaption = false; // Hide collapse screen caption band DataGridView dgv = new DataGridView(); nvbContacts = new NavigateBarButton(); nvbContacts.Caption = "Contacts"; nvbContacts.CaptionDescription = "My Friends"; nvbContacts.Image = Properties.Resources.Contacts24; nvbContacts.RelatedControl = dgv; nvbContacts.IsShowCaption = false; nvbContacts.IsShowCaptionDescription = true; nvbContacts.Key = "CONTACTS"; nvbContacts.IsAlwaysDisplayed = true; // Always show in panel nvbContacts.CollapsedScreenWidth = 240; // For Contacts button nvbTasks = new NavigateBarButton(new RichTextBox()); nvbTasks.Caption = "Tasks"; nvbTasks.CaptionDescription = "My Tasks"; nvbTasks.Image = Properties.Resources.Tasks24; nvbTasks.MouseOverImage = Properties.Resources.Contacts24; nvbTasks.SelectedImage = Properties.Resources.Mail24; nvbTasks.ToolTipText = "ToolTipText for tasks"; //nvbTasks.Enabled = false; nvbTasks.IsShowCaption = false; nvbTasks.IsShowCaptionDescription = false; nvbTasks.Key = "TASKS"; nvbNotes = new NavigateBarButton("Notes", Properties.Resources.Notes24); nvbNotes.Key = "NOTES"; nvbFolderList = new NavigateBarButton("Folder List", Properties.Resources.FolderList24); nvbFolderList.Key = "FOLDERLIST"; nvbShortCuts = new NavigateBarButton("Shortcuts", Properties.Resources.Shortcut24); nvbShortCuts.Key = "SHORTCUT"; nvbDiary = new NavigateBarButton("Diary", Properties.Resources.Diary24); nvbDiary.Key = "DIARY"; outlookNavigatePane.NavigateBarButtons.AddRange(new NavigateBarButton[] { nvbMail, nvbCalendar, nvbContacts }); outlookNavigatePane.NavigateBarButtons.Add(nvbTasks); outlookNavigatePane.NavigateBarButtons.Add(nvbNotes); outlookNavigatePane.NavigateBarButtons.Add(nvbFolderList); outlookNavigatePane.NavigateBarButtons.Add(nvbShortCuts); outlookNavigatePane.NavigateBarButtons.Add(nvbDiary); #endregion #region Strips // ToolStrip toolStrip = new ToolStrip(); toolStrip.RenderMode = ToolStripRenderMode.ManagerRenderMode; tbtnMDIChildForm = new ToolStripButton(); tbtnMDIChildForm.Text = "MDI Child"; tbtnMDIChildForm.Click += new EventHandler(tbtnMDIChildForm_Click); tbtnAbout = new ToolStripButton(); tbtnAbout.Text = "About"; tbtnAbout.Click += delegate(object sender, EventArgs e) { Type typ = typeof(TestMainForm); object[] r = typ.Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); AssemblyCopyrightAttribute ct = (AssemblyCopyrightAttribute)r[0]; object[] d = typ.Assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); AssemblyDescriptionAttribute dt = (AssemblyDescriptionAttribute)d[0]; object[] v = typ.Assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false); AssemblyFileVersionAttribute vt = (AssemblyFileVersionAttribute)v[0]; MessageBox.Show(ct.Copyright + "\n\n" + dt.Description + "\n\n" + "Version : " + vt.Version); }; tbtnExit = new ToolStripButton(); tbtnExit.Text = "Exit"; tbtnExit.Click += delegate(object sender, EventArgs e) { this.Close(); }; toolStrip.Items.Add(tbtnMDIChildForm); toolStrip.Items.Add(new ToolStripSeparator()); toolStrip.Items.Add(tbtnAbout); toolStrip.Items.Add(tbtnExit); // MenuStrip menuStrip = new MenuStrip(); menuStrip.RenderMode = ToolStripRenderMode.ManagerRenderMode; menuStrip.Dock = DockStyle.Top; MainMenuStrip = menuStrip; // StatusStrip statusStrip = new StatusStrip(); statusStrip.RenderMode = ToolStripRenderMode.ManagerRenderMode; #endregion // Splitter splitterNavigateMenu = new MTSplitter(); splitterNavigateMenu.Size = new Size(7, 100); splitterNavigateMenu.SplitterPointCount = 10; splitterNavigateMenu.SplitterPaintAngle = 360F; splitterNavigateMenu.Dock = DockStyle.Left; // Navigatebar Remote Control nbRemoteControl = new NhapThongTinBenhNhan(outlookNavigatePane); nbRemoteControl.Dock = DockStyle.Fill; containerControlProp = new ContainerControl(); containerControlProp.Width = nbRemoteControl.Width; containerControlProp.Controls.Add(nbRemoteControl); containerControlProp.Dock = DockStyle.Right; Controls.AddRange(new Control[] { splitterNavigateMenu, outlookNavigatePane, containerControlProp, toolStrip, statusStrip, menuStrip }); }