コード例 #1
0
        /// <summary>
        /// Handles notification that the specified networksetting was changed, added, or removed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="networkSetting"></param>
        private void ConfigurationChanged_EventHandler(object sender, NetWorkSetting networkSetting)
        {
            // Invalidate the request cache for network when things change on the connection since the user name or URL may have changed.  We could be more selective in when we need to invalidate, but for now this will do.
            RequestCache.ForNetwork(networkSetting).Invalidate();

            if (!this.Visible)
            {
                return;
            }

            try
            {
                TestConnections();

                //determine if the networksetting was added, deleted, or changed
                RequestListGridView gridView = tabs.TabPages.Cast <TabPage>().Select(tp => tp.Controls[0] as RequestListGridView).Where(gv => gv != null && gv.Network.CredentialKey == networkSetting.CredentialKey).FirstOrDefault();

                if (gridView == null)
                {
                    //new network
                    gridView = CreateList(networkSetting);
                }
                else if (!Configuration.Instance.NetworkSettingCollection.NetWorkSettings.Cast <NetWorkSetting>().Any(n => n.CredentialKey == networkSetting.CredentialKey))
                {
                    //network was deleted
                    tabs.TabPages.Remove((TabPage)gridView.Parent);

                    gridView.StopAutoprocessor();
                    gridView.Dispose();
                    gridView = null;
                }
                else
                {
                    //network setting changed
                    gridView.OnConfigurationChanged(networkSetting);
                }

                ToggleNoNetworksMessage();

                ReloadAllLists();

                RefreshAutoResponse();
            }
            catch (Exception ex)
            {
                log.Error(ex);
                MessageBox.Show(ex.Message, "Unexpected Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        RequestListGridView CreateList(NetWorkSetting ns)
        {
            var existing = AllLists().FirstOrDefault(l => l.Network == ns);

            if (existing != null)
            {
                return(existing);
            }

            var g = new RequestListGridView(ns)
            {
                Dock            = DockStyle.Fill,
                Filter          = ns.Filter,
                PageSize        = ns.PageSize,
                SortColumn      = ns.Sort,
                IsSortAscending = ns.SortAscending
            };

            var tab = new TabPage {
                Text = ns.NetworkName, Controls = { g }
            };

            tabs.TabPages.Add(tab);
            tab.ImageKey = TabIcon_Regular;

            g.RequestRowDoubleClick  += rlgvRequestList_RequestRowDoubleClick;
            g.ReloadStarted          += (_, __) => SetReloadingStatusText();
            g.SelectedRequestChanged += (_, __) => ToggleDetailsButton();
            g.Reloaded     += (_, __) => { SetReloadingStatusText(); ToggleDetailsButton(); SetNewRequestsIndicator(tab); };
            g.ReloadFailed += (_, __) => { SetReloadingStatusText(); ToggleDetailsButton(); SetNewRequestsIndicator(tab); };
            g.NewRequestsAvailableChanged += (_, __) => { SetNewRequestsIndicator(tab); ResetNewRequestsIndicator(); };

            EventHandler saveGridSettings = (_, __) =>
            {
                ns.PageSize      = g.PageSize;
                ns.Filter        = g.Filter;
                ns.SortAscending = g.IsSortAscending;
                ns.Sort          = g.SortColumn;
                Configuration.SaveNetworkSettings();
            };

            g.FilterChanged   += saveGridSettings;
            g.PageSizeChanged += saveGridSettings;
            g.SortModeChanged += saveGridSettings;

            SetNewRequestsIndicator(tab);

            return(g);
        }