Esempio n. 1
0
        private void ResetSourceFilterButtons()
        {
            this.toolStrip.SuspendLayout();
            foreach (var pair in this.sourceFilterButtons)
            {
                // Special case for the default three logs
                if (pair.Key == Logs.Core.Id)
                {
                    continue;
                }
                if (pair.Key == Logs.Editor.Id)
                {
                    continue;
                }
                if (pair.Key == Logs.Game.Id)
                {
                    continue;
                }

                ToolStripButton button = pair.Value;
                this.toolStrip.Items.Remove(button);
                button.CheckedChanged -= this.sourceFilterButton_CheckedChanged;
                button.Dispose();
            }
            this.toolStrip.ResumeLayout();

            this.sourceFilterButtons.Clear();
            this.sourceFilterButtons.Add(Logs.Core.Id, this.buttonCore);
            this.sourceFilterButtons.Add(Logs.Editor.Id, this.buttonEditor);
            this.sourceFilterButtons.Add(Logs.Game.Id, this.buttonGame);
        }
Esempio n. 2
0
        ///<summary>
        ///  Registers new Tool Box button in main tool-set
        ///</summary>
        ///<param name="ownControl">Control owns button will be created</param>
        ///<param name="item">Instance of <see cref="ToolStripMenuItem"/> which provides information to create button</param>
        ///<param name="action">Action should be call when created button clicked</param>
        ///<returns>Action delegate to notify main form when created button should be enabled/disabled</returns>
        ///<exception cref="FireFlyException"></exception>
        public Action <bool> RegisterToolBoxButton([NotNull] Control ownControl, [NotNull] ToolStripMenuItem item, [CanBeNull] EventHandler action)
        {
            var nb = new ToolStripButton(item.Text, item.Image)
            {
                Name = item.Name, ToolTipText = item.ToolTipText, Tag = ownControl, Visible = false
            };

            if (item.ShortcutKeys != Keys.None)
            {
#if CHECKERS
                if (nb.ToolTipText.IsNull())
                {
                    throw new FireFlyException("{0} has empty ToolTipText property", nb.Name);
                }
#endif
                nb.ToolTipText += " (" + new KeysConverter().ConvertToString(item.ShortcutKeys) + ")";
            }
            nb.DisplayStyle = item.Image != null ? ToolStripItemDisplayStyle.Image : ToolStripItemDisplayStyle.Text;
            nb.Click       += action ?? ((s, e) => item.PerformClick());
            nb.Enabled      = item.Visible && item.Enabled;
            tsMain.Items.Add(nb);

            ownControl.GotFocus  += (s, e) => nb.Visible = true;
            ownControl.LostFocus += (s, e) =>
            {
                nb.Visible = false;
            };
            ownControl.Disposed += (s, e) => nb.Dispose();

            return(isActive =>
            {
                nb.Enabled = isActive;
                item.Visible = isActive;
            });
        }
Esempio n. 3
0
        public void Close()
        {
            if (!allowClose) return;

            if (control != null)
            {
                if (control.Parent != null && control.Parent is Form)
                {
                    control.Parent.Dispose();
                }

                if (instance.TabConsole.toolStripContainer1.ContentPanel.Contains(control))
                {
                    instance.TabConsole.toolStripContainer1.ContentPanel.Controls.Remove(control);
                }
                control.Dispose();
                control = null;
            }

            if (button != null)
            {
                if (instance.TabConsole.tstTabs.Items.Contains(button))
                {
                    instance.TabConsole.tstTabs.Items.Remove(button);
                }
                button.Dispose();
                button = null;
            }


            OnTabClosed(EventArgs.Empty);
        }
Esempio n. 4
0
        private void clearToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (contextTSB == null)
            {
                return;
            }

            string mypath = contextTSB.ToolTipText;
            //Properties.Settings.Default.Favs.Remove(mypath);

            string mycaption = contextTSB.Text;


            int i = applicationSettings.sections.GetItemIDByString(sectionName, "FAV");

            if (i > -1)
            {
                //Section section = applicationSettings.sections.GetItemByString(mypath);
                int     settingID = applicationSettings.sections[i].settings.GetItemIDByString(mycaption);
                Setting setting   = applicationSettings.sections[i].settings.GetItemByString(mycaption);
                applicationSettings.sections[i].settings.Remove(setting);
                //applicationSettings.sections.Remove(section);
            }


            contextTSB.Dispose();
        }
Esempio n. 5
0
        private void removeTab(ToolStripButton tabToRemove)
        {
            tabToRemove.Click     -= new System.EventHandler(this.CommonChangeTab_Click);
            tabToRemove.MouseDown -= this.CommonCloseTab_Click;

            this.toolStrip1.Items.Remove(tabToRemove);
            tabToRemove.Dispose();
        }
Esempio n. 6
0
        /// <inheritdoc />
        public override void Deinitialize()
        {
            if (_button != null)
            {
                _button.Dispose();
                _button = null;
            }

            base.Deinitialize();
        }
Esempio n. 7
0
        private void clearToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (contextTSB == null)
            {
                return;
            }

            string mypath = contextTSB.ToolTipText;

            RemoveFavItem(mypath);
            Properties.Settings.Default.Favs.Remove(mypath);
            contextTSB.Dispose();
        }
Esempio n. 8
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         fList.Dispose();
         fBtnLinkJump.Dispose();
         fBtnMoveUp.Dispose();
         fBtnMoveDown.Dispose();
         fBtnDelete.Dispose();
         fBtnEdit.Dispose();
         fBtnAdd.Dispose();
         fToolBar.Dispose();
     }
     base.Dispose(disposing);
 }
Esempio n. 9
0
        public void Close(EndCode code)
        {
            pluginServer = null;
            shellBrowser = null;

            if (button != null)
            {
                button.Dispose();
            }

            if (fvmw != null)
            {
                fvmw.Dispose();
            }
        }
Esempio n. 10
0
        private void CloseTab(ToolStripButton tab)
        {
            // Remove the tab from the collection
            this.toolStrip1.Items.Remove(tab);
            tab.Dispose();

            // Uncheck the corresponding tab in the drop down
            foreach (ToolStripItem dropDownItem in this.windowsDropDownButton.DropDownItems)
            {
                ToolStripMenuItem menuItem = dropDownItem as ToolStripMenuItem;
                if ((menuItem != null) && (menuItem.Text == tab.Text))
                {
                    // Uncheck the item
                    menuItem.Checked = false;

                    IToolWindow toolWindow = menuItem.Tag as IToolWindow;
                    if (toolWindow != null)
                    {
                        // Remove the ToolWindow
                        hostPanel.Controls.Remove(toolWindow.View);

                        // If this is the last toolwindow open, remove the panel
                        if (hostPanel.Controls.Count == 0)
                        {
                            int tempSize = this.Width;
                            this.Width  = this.toolStrip1.Width;
                            restoreSize = tempSize;
                        }

                        // Raise the unchecked event
                        OnToolWindowUnchecked(new ToolWindowEventArgs(toolWindow));
                    }
                    break;
                }
            }

            // Set first tab to be active
            foreach (ToolStripItem item in this.toolStrip1.Items)
            {
                tab = item as ToolStripButton;
                if ((tab != null) && (tab.Text != "r"))
                {
                    SetActiveTab(tab);
                    break;
                }
            }
        }
        /// <summary>
        /// Show a PrintPreviewDialog for the specified PrintDocument.
        /// </summary>
        /// <param name="pdoc">Specifies the PrintDocument to be previewed.</param>
        /// <param name="showPrintDialog">Specifies whether to show the PrintSettings dialog.</param>
        static public void ChartPreviewDialogEx(PrintDocument pdoc, bool showPrintDialog)
        {
            PrintPreviewDialog ppd = new PrintPreviewDialog();

            ppd.Document = pdoc;

            ToolStripButton b = null;

            if (showPrintDialog)
            {
                // Replace the existing Print button with one that issues a print dialog
                // prior to printing.  This allows a printer other than default.
                ToolStripButton bb = (ToolStripButton)((ToolStrip)(ppd.Controls[1])).Items[0];
                b              = new ToolStripButton();
                b.Image        = bb.Image;
                b.DisplayStyle = ToolStripItemDisplayStyle.Image;
                bb.Dispose();
                bb = null;

                ((ToolStrip)(ppd.Controls[1])).Items.RemoveAt(0);
                ((ToolStrip)(ppd.Controls[1])).Items.Insert(0, b);

                b.Click += (o, e) =>
                {
                    using (PrintDialog pdlg = new PrintDialog())
                    {
                        pdlg.Document = ppd.Document;
                        if (pdlg.ShowDialog(ppd) == DialogResult.OK)
                        {
                            pdlg.Document.PrinterSettings = pdlg.PrinterSettings;
                            pdlg.Document.Print();
                        }
                    }
                };
            }
            Size screenSize = Screen.FromControl(ppd).WorkingArea.Size;

            ppd.ClientSize = new Size(screenSize.Width * 3 / 4, screenSize.Height * 3 / 4);
            ppd.ShowDialog();
            ppd.Dispose();

            if (b != null)
            {
                b.Dispose();
            }
        }
Esempio n. 12
0
 public void End()
 {
     _setting.Save(_path);
     SaveKujiSettings();
     if (_toolStripSeparator != null)
     {
         Pub.ToolStrip.Items.Remove(_toolStripSeparator);
         _toolStripSeparator.Dispose();
         _toolStripSeparator = null;
     }
     if (_toolStripButton != null)
     {
         Pub.ToolStrip.Items.Remove(_toolStripButton);
         _toolStripButton.Dispose();
         _toolStripButton = null;
     }
     return;
 }
Esempio n. 13
0
        void item_DoubleClick(object sender, EventArgs e)
        {
            ToolStripButton item = sender as ToolStripButton;
            Form            form = item.Tag as Form;

            if (form != null && !form.IsDisposed)
            {
                form.Close();
            }

            this.Items.Remove(item);
            item.Dispose();

            //foreach (Form f in MdiParent.MdiChildren)
            //{
            //    if (f.Focused && f != form) OpenMdiChild(f);
            //}
        }
Esempio n. 14
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }

            if (m_MyToolStripButton != null)
            {
                m_MyToolStripButton.Dispose();
                m_MyToolStripButton = null;
            }

            base.Dispose(disposing);
        }
            /// <summary>
            /// protected disposal method
            /// </summary>
            /// <param name="disposing"></param>
            protected virtual void Dispose(bool disposing)
            {
                if (!this.disposed)
                {
                    // Cleanup up managed resources
                    //
                    if (disposing)
                    {
                        button.Dispose();
                        menuItem.Dispose();
                        navPaneControl.Dispose();
                    }

                    // Clean up any unmanaged resources here
                    //
                }

                disposed = true;
            }
Esempio n. 16
0
        public void Close()
        {
            if (!allowClose)
            {
                return;
            }

            if (button != null)
            {
                button.Dispose();
                button = null;
            }

            if (control != null)
            {
                control.Dispose();
                control = null;
            }

            OnTabClosed(EventArgs.Empty);
        }
Esempio n. 17
0
        private void LoadControls()
        {
            SetPnlViewerSize();
            pdfViewer.LoadFile("manual.pdf");



            pnlRgnts.Controls.Clear();

            DataTable dt1 = dbo.GetTable("Reagent_Data");
            DataTable dt2 = dbo.GetTable("Operation_Data");

            int y = 10;

            List <string> lstTempReagentCode = new List <string>();
            List <string> lstTempReagentName = new List <string>();

            foreach (DataRow dr in dt1.Rows)
            {
                lstTempReagentName.Add(Convert.ToString(dr.ItemArray[2]));
            }

            lstTempReagentName.Sort();

            for (int i = 0; i < lstTempReagentName.Count; i++)
            {
                var rjntName = lstTempReagentName[i];

                for (int j = 0; j < lstTempReagentName.Count; j++)
                {
                    string reagentNameFromTable = Convert.ToString(dt1.Rows[j].ItemArray[2]);
                    if (reagentNameFromTable == rjntName)
                    {
                        var rjntCode = Convert.ToString(dt1.Rows[j].ItemArray[1]);
                        lstTempReagentCode.Add(rjntCode);
                        break;
                    }
                }
            }


            for (int i = 0; i < lstTempReagentCode.Count; i++)
            {
                var reagentCode = lstTempReagentCode[i];
                var reagentName = lstTempReagentName[i];

                CustomButton cb = new CustomButton();
                cb.ReagentOrOperationCode = reagentCode;
                cb.ReagentOrOperationName = reagentName;


                cb.Size     = new Size(236, 32);
                cb.Location = new Point(2, y);

                Font fnt = new System.Drawing.Font("Cambria", 11.25f);
                cb.Font      = fnt;
                cb.TextAlign = ContentAlignment.MiddleCenter;
                cb.Text      = reagentName;

                cb.Click += new EventHandler(cb_Click);
                pnlRgnts.Controls.Add(cb);

                y += 32;
            }



            foreach (DataRow dr in dt2.Rows)
            {
                ToolStripButton tsbToDispose = new ToolStripButton();
                foreach (ToolStripButton toolStripBtn in toolStripMainForm.Items.OfType <ToolStripButton>())
                {
                    if (toolStripBtn.ToolTipText == Convert.ToString(dr.ItemArray[2]))
                    {
                        tsbToDispose = toolStripBtn;
                        break;
                    }
                }

                string imageLink = dr.ItemArray[3] as string;

                tsbToDispose.Dispose();

                CustomToolStripButton tsb = new CustomToolStripButton();
                tsb.OperationCode = Convert.ToString(dr.ItemArray[1]);
                tsb.OperationName = Convert.ToString(dr.ItemArray[2]);

                try
                {
                    tsb.Image = new Bitmap(imageLink);
                }
                catch
                {
                    tsb.Image = new Bitmap("operation.png");
                }


                tsb.ImageAlign   = ContentAlignment.MiddleCenter;
                tsb.ImageScaling = ToolStripItemImageScaling.None;
                tsb.Size         = new System.Drawing.Size(52, 48);
                tsb.Alignment    = ToolStripItemAlignment.Left;
                tsb.ToolTipText  = tsb.OperationName;
                toolStripMainForm.Items.Add(tsb);

                tsb.Click += new EventHandler(tsb_Click);
            }
        }