Ejemplo n.º 1
0
        public StartPage(IConnectionsGraph recent, IConnectionsGraph faves)
        {
            InitializeComponent();

            this.FillConnectionList(recent, this.lstRecent);
            this.FillConnectionList(faves, this.lstFaves);
            this.chkAlwaysEdit.Checked = Settings.Default.AlwaysEdit;
            this.chkAlwaysShow.Checked = Settings.Default.ShowStartPage;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new Open Connection Form
        /// </summary>
        /// <param name="connections">Graph contaning Connection Definitions</param>
        public OpenConnectionForm(IConnectionsGraph connections)
        {
            InitializeComponent();

            foreach (Connection connection in connections.Connections)
            {
                this.lstConnections.Items.Add(connection);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new list view with the given data source
        /// </summary>
        /// <param name="connections">Data source</param>
        public ConnectionManagementListView(IConnectionsGraph connections)
            : this()
        {
            if (connections == null)
            {
                throw new ArgumentNullException("connections");
            }
            this._connections = connections;
            this.BindData();

            // Subscribe to events on connections graph
            this._connections.CollectionChanged += this._handler;
        }
Ejemplo n.º 4
0
 private void FillConnectionList(IConnectionsGraph connections, ListBox lbox)
 {
     foreach (Connection connection in connections.Connections)
     {
         lbox.Items.Add(connection);
     }
     lbox.DoubleClick += (sender, args) =>
     {
         Connection connection = lbox.SelectedItem as Connection;
         if (connection == null)
         {
             return;
         }
         if (Settings.Default.AlwaysEdit)
         {
             if (connection.IsOpen)
             {
                 MessageBox.Show(Resources.EditConnection_Forbidden_Text, Resources.EditConnection_Forbidden_Title, MessageBoxButtons.OK, MessageBoxIcon.Information);
                 return;
             }
             EditConnectionForm edit = new EditConnectionForm(connection, false);
             if (edit.ShowDialog() == DialogResult.OK)
             {
                 connection = edit.Connection;
                 try
                 {
                     connection.Open();
                     Program.MainForm.ShowStoreManagerForm(connection);
                     this.Close();
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(string.Format(Resources.StartPage_Open_Error_Text, connection.Name, ex.Message), Resources.ConnectionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
         else
         {
             try
             {
                 connection.Open();
                 Program.MainForm.ShowStoreManagerForm(connection);
                 this.Close();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(string.Format(Resources.StartPage_Open_Error_Text, connection.Name, ex.Message), Resources.ConnectionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     };
 }
Ejemplo n.º 5
0
        private void FillConnectionsMenu(ToolStripDropDownItem menu, IConnectionsGraph config, int maxItems)
        {
            // Clear existing items (except the items that are the clear options)
            while (menu.DropDownItems.Count > 2)
            {
                menu.DropDownItems.RemoveAt(2);
            }
            if (config == null || config.Count == 0)
            {
                return;
            }

            int count = 0;

            foreach (Connection connection in config.Connections)
            {
                ToolStripMenuItem item = new ToolStripMenuItem {
                    Text = connection.Name, Tag = connection
                };
                item.Click += QuickConnectClick;

                ToolStripMenuItem edit = new ToolStripMenuItem {
                    Text = Resources.EditConnection, Tag = item.Tag
                };
                edit.Click += QuickEditClick;
                item.DropDownItems.Add(edit);

                menu.DropDownItems.Add(item);

                count++;
                if (maxItems > 0 && count >= maxItems)
                {
                    break;
                }
            }
        }
Ejemplo n.º 6
0
        private static void ClearConnections(ToolStripMenuItem menu, IConnectionsGraph connections)
        {
            if (connections == null)
            {
                return;
            }
            try
            {
                connections.Clear();
            }
            catch (Exception ex)
            {
                Program.HandleInternalError(Resources.ClearConnections_Error, ex);
            }

            if (menu == null)
            {
                return;
            }
            while (menu.DropDownItems.Count > 2)
            {
                menu.DropDownItems.RemoveAt(2);
            }
        }
Ejemplo n.º 7
0
        private void HandleConnectionsGraphChanged(NotifyCollectionChangedEventArgs args, IConnectionsGraph connections, ToolStripMenuItem item, int maxItems)
        {
            switch (args.Action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (Connection connection in args.NewItems.OfType <Connection>())
                {
                    this.AddConnectionToMenu(connection, item);
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (Connection connection in args.OldItems.OfType <Connection>())
                {
                    RemoveConnectionFromMenu(connection, item);
                }
                break;

            default:
                this.FillConnectionsMenu(item, connections, maxItems);
                break;
            }
        }