Exemplo n.º 1
0
        private void Open()
        {
            DialogResult _dialogResult = openFileDialog1.ShowDialog();

            if (_dialogResult == DialogResult.OK)
            {
                if (!string.IsNullOrEmpty(openFileDialog1.FileName))
                {
                    FileInfo _fileInfo = new FileInfo(openFileDialog1.FileName);

                    if (_fileInfo.Exists)
                    {
                        Form_MainBase _form_MainBase = this.ObtainNewForm(_fileInfo);

                        if (_form_MainBase != null)
                        {
                            Main.ObtainNewForm(_form_MainBase);

                            //če v tej inštanci ni nič pametnega in/ali nimamo sprememb v zraku, ugasnemo trenutno okno
                            if ((!this.editedFile.Exists) &&
                                (this.changesSaved))
                            {
                                this.Close();
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected void StartNewWindow(Form_MainBase _form_MainBase)
        {
            Main.ObtainNewForm(_form_MainBase);

            if (this.changesSaved)
            {
                this.Close();
            }
        }
Exemplo n.º 3
0
        internal static Form_MainBase ObtainNewForm(Form_MainBase _form_MainBase)
        {
            _form_MainBase.FormClosed
                += new FormClosedEventHandler(_form_MainBase_FormClosed);
            Main.activeForms.Add(_form_MainBase);
            _form_MainBase.Show();

            return(_form_MainBase);
        }
Exemplo n.º 4
0
        private void toolStripMenuItem_Window_DropDownOpening(object sender, EventArgs e)
        {
            #region "najprej odstranimo vse"
            List <ToolStripMenuItem> _toolStripMenuItemsToRemove = new List <ToolStripMenuItem>();
            _toolStripMenuItemsToRemove.AddRange(toolStripMenuItem_Window.DropDownItems.OfType <ToolStripMenuItem>());

            foreach (ToolStripMenuItem _toolStripMenuItem in _toolStripMenuItemsToRemove)
            {
                //seveda samo tiste, ki imajo formo v tagu
                if (_toolStripMenuItem.Tag is Form_MainBase)
                {
                    _toolStripMenuItem.Click
                        -= new EventHandler(toolStripMenuItem_Window_Item_Click);

                    toolStripMenuItem_Window.DropDownItems.Remove(_toolStripMenuItem);
                }
            }
            #endregion "najprej odstranimo vse"

            #region "dodamo morebitne forme na menu, v pravem vrstnem redu"
            Form_MainBase _activeForm = null;
            #region "poiščemo aktivno formo"
            foreach (Form_MainBase _form_MainBase in Main.ActiveForms)
            {
                //če je to naša forma, potem je seveda aktivna!
                if (_form_MainBase == this)
                {
                    _activeForm = _form_MainBase;
                    break;
                }
            }

            //če nismo našli nobene, vzamemo pač prvo
            if (_activeForm == null)
            {
                _activeForm = Main.ActiveForms.ElementAt(0);
            }
            #endregion "poiščemo aktivno mdi formo"

            #region "dodamo aktivno, da je na vrhu in jo čekiramo"
            int _menuItemPosition = 0;
            AddMenuItem(_activeForm, _menuItemPosition, true);
            #endregion "dodamo aktivno, da je na vrhu in jo čekiramo"

            #region "dodamo vse forme, razen aktivne - torej so pod aktivno in niso čekirane"
            foreach (Form_MainBase _form_MainBase in Main.ActiveForms)
            {
                if (_form_MainBase != _activeForm)
                {
                    _menuItemPosition++;
                    this.AddMenuItem(_form_MainBase, _menuItemPosition, false);
                }
            }
            #endregion "dodamo vse forme, razen aktivne - torej so pod aktivno in niso čekirane"
            #endregion "dodamo morebitne forme na menu, v pravem vrstnem redu"
        }
Exemplo n.º 5
0
        private void toolStripMenuItem_Window_Item_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem _toolStripMenuItem_mdiChild = (ToolStripMenuItem)sender;
            Form_MainBase     _form_MainBase = (Form_MainBase)_toolStripMenuItem_mdiChild.Tag;

            //če je to naša forma, potem je seveda aktivna!
            if (_form_MainBase != this)
            {
                _form_MainBase.Activate();
            }
        }
Exemplo n.º 6
0
        private void button_Close_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem _listViewItem in listView1.SelectedItems)
            {
                Form_MainBase _form_MainBase = (Form_MainBase)_listViewItem.Tag;

                _form_MainBase.FormClosed += delegate(object _sender, FormClosedEventArgs _e)
                {
                    listView1.Items.Remove(_listViewItem);
                };

                _form_MainBase.Close();
            }

            SetListViewWidth();
        }
Exemplo n.º 7
0
        private void ActivateItem()
        {
            foreach (ListViewItem _listViewItem in listView1.SelectedItems)
            {
                if (_listViewItem.Focused)
                {
                    Form_MainBase _form_MainBase = (Form_MainBase)_listViewItem.Tag;
                    if (!_form_MainBase.Focused)
                    {
                        _form_MainBase.Activate();
                        lastActivatedForm = _form_MainBase;
                    }

                    break;
                }
            }
        }
Exemplo n.º 8
0
        private void Form_Windows_FormClosing(object sender, FormClosingEventArgs e)
        {
            #region "pogledamo, če 'lastActivatedForm' še vedno obstaja, ali pa smo jo mogoče zaprli"
            bool _lastActivatedFormStillExists = false;
            foreach (ListViewItem _listViewItem in listView1.SelectedItems)
            {
                Form_MainBase _form_MainBase = (Form_MainBase)_listViewItem.Tag;
                if (_form_MainBase == lastActivatedForm)
                {
                    _lastActivatedFormStillExists = true;
                    break;
                }
            }

            if (!_lastActivatedFormStillExists)
            {
                lastActivatedForm = null;
            }
            #endregion "pogledamo, če 'lastActivatedForm' še vedno obstaja, ali pa smo jo mogoče zaprli"
        }
Exemplo n.º 9
0
        private void AddMenuItem(Form_MainBase _form_MainBase, int _positionInMenu, bool _checked)
        {
            ToolStripMenuItem _toolStripMenuItem = new ToolStripMenuItem();

            _toolStripMenuItem.Checked      = _checked;
            _toolStripMenuItem.CheckOnClick = true;

            int _itemIndex = _positionInMenu + 1;

            _toolStripMenuItem.Text = string.Format(
                "{0} {1}",
                _itemIndex.ToString(),
                _form_MainBase.caption);

            _toolStripMenuItem.Tag = _form_MainBase;

            _toolStripMenuItem.Click
                += new EventHandler(toolStripMenuItem_Window_Item_Click);


            //this.toolStripMenuItem_Window.DropDownItems.Add(_toolStripMenuItem);
            this.toolStripMenuItem_Window.DropDownItems.Insert(_positionInMenu, _toolStripMenuItem);
        }