Exemplo n.º 1
0
        //////////////////////////////////////////////////////////////////////////
        private void WeedSeparators(ToolStripItemCollection Items, bool RemoveSeparators)
        {
            bool PrevSeparator = true;

            for (int i = 0; i < Items.Count; i++)
            {
                if (!Items[i].Available)
                {
                    continue;
                }

                if (Items[i] is ToolStripSeparator)
                {
                    if (PrevSeparator)
                    {
                        if (RemoveSeparators)
                        {
                            Items.RemoveAt(i);
                            i--;
                        }
                        else
                        {
                            Items[i].Available = false;
                        }
                    }
                    PrevSeparator = true;
                }
                else
                {
                    PrevSeparator = false;
                }
            }

            PrevSeparator = true;
            for (int i = Items.Count - 1; i >= 0; i--)
            {
                if (!Items[i].Available)
                {
                    continue;
                }

                if (Items[i] is ToolStripSeparator && PrevSeparator)
                {
                    if (RemoveSeparators)
                    {
                        Items.RemoveAt(i);
                    }
                    else
                    {
                        Items[i].Available = false;
                    }
                }
                else
                {
                    break;
                }
            }
        }
Exemplo n.º 2
0
        private void fileToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            // Update MRU on file menu
            if (Program.mru.mruFiles.Count > 0)
            {
                ToolStripItemCollection items = fileToolStripMenuItem.DropDownItems;

                int index = 0;
                for (; index < items.Count; index++)
                {
                    if ((string)items[index].Tag == "MRU")
                    {
                        // Remove anything after the tag, till the next separator
                        while (items.Count > index + 1 && !(items[index + 1] is ToolStripSeparator))
                        {
                            items.RemoveAt(index + 1);
                        }
                        // Hide tag
                        items[index].Visible = false;
                        index++;
                        // Add MRUs
                        foreach (MRUFile f in Program.mru.mruFiles)
                        {
                            ToolStripMenuItem item = new ToolStripMenuItem(f.filename);
                            item.ToolTipText = f.filepath;
                            items.Insert(index, item);
                            item.Click += MRU_Item_Click;
                            index++;
                        }
                        break;
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handles the DropDownOpening event of the mnuWindow control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// ------------------------------------------------------------------------------------
        private void mnuWindow_DropDownOpening(object sender, EventArgs e)
        {
            // Remove all the windows names at the end of the Windows menu list.
            ToolStripItemCollection wndMenus = mnuWindow.DropDownItems;

            for (int i = wndMenus.Count - 1; wndMenus[i] != mnuWindowsSep; i--)
            {
                wndMenus[i].Click -= HandleWindowMenuItemClick;
                wndMenus.RemoveAt(i);
            }

            // Now add a menu item for each document in the dock panel.
            foreach (IDockContent dc in m_dockPanel.Documents)
            {
                DockContent       wnd = dc as DockContent;
                ToolStripMenuItem mnu = new ToolStripMenuItem();
                mnu.Text    = wnd.Text;
                mnu.Tag     = wnd;
                mnu.Checked = (m_dockPanel.ActiveContent == wnd);
                mnu.Click  += HandleWindowMenuItemClick;
                mnuWindow.DropDownItems.Add(mnu);
            }

            mnuTileVertically.Enabled   = (m_dockPanel.DocumentsCount > 1);
            mnuTileHorizontally.Enabled = (m_dockPanel.DocumentsCount > 1);
            mnuArrangeInline.Enabled    = (m_dockPanel.DocumentsCount > 1);
        }
Exemplo n.º 4
0
        void SyncRecentFilesMenu()
        {
            // Synchronize menu items.
            if (this.recentFiles.Count == 0)
            {
                return;
            }
            this.parent.Enabled = true;

            ToolStripItemCollection ic = this.parent.DropDownItems;

            // Add most recent files first.
            for (int i = this.recentFiles.Count - 1, j = 0; i >= 0; i--, j++)
            {
                ToolStripItem item = null;
                if (ic.Count > j)
                {
                    item = ic[j];
                }
                else
                {
                    item        = new ToolStripMenuItem();
                    item.Click += new EventHandler(OnRecentFile);
                    ic.Add(item);
                }
                Uri uri = this.recentFiles[i];
                item.Text = uri.IsFile ? uri.LocalPath : uri.AbsoluteUri;
            }

            // Remove any extra menu items.
            for (int i = ic.Count - 1, n = this.recentFiles.Count; i > n; i--)
            {
                ic.RemoveAt(i);
            }
        }
Exemplo n.º 5
0
        private void SetupContextMenu(ToolStripItemCollection items)
        {
            while (items[0] != mReRead)
            {
                var menuItem = items[0];
                items.RemoveAt(0);
                menuItem.Dispose();
            }
            m_FactoryManager.CreateDefaultRoots();
            var index = 0;

            foreach (var root in m_FactoryManager.DefaultRoots)
            {
                var menuItem = new ToolStripMenuItem(string.Format(Resources.PagesView_OpenTab, root.Name));
                menuItem.Tag        = root;
                menuItem.ImageIndex = App.Images.IndexOf(root.ImageName);
                menuItem.Click     += PluginOnClick;
                items.Insert(index, menuItem);
                index++;
            }
            if (index > 0)
            {
                items.Insert(index, new ToolStripSeparator());
            }
        }
Exemplo n.º 6
0
        private static void CalculateOverflow(ContextMenuStrip contextMenu,
                                              ToolStripItemCollection items, int maxHeight)
        {
            int height = contextMenu.Padding.Top;

            contextMenu.PerformLayout();
            int  totalItems     = items.Count;
            int  overflowIndex  = 0;
            bool overflowNeeded = false;

            // only examine up to last but one item.
            for (; overflowIndex < totalItems - 2; ++overflowIndex)
            {
                ToolStripItem current = items[overflowIndex];
                ToolStripItem next    = items[overflowIndex + 1];
                if (!current.Available)
                {
                    continue;
                }

                height += GetTotalHeight(current);

                if (height + GetTotalHeight(next) + contextMenu.Padding.Bottom > maxHeight)
                {
                    overflowNeeded = true;
                    break;
                }
            }

            if (overflowNeeded)
            {
                // Don't dispose overflow here because that will prevent it from working.
                ToolStripMenuItem overflow = new ToolStripMenuItem(FwCoreDlgControls.kstid_More, Images.arrowright);
                overflow.ImageScaling = ToolStripItemImageScaling.None;
                overflow.ImageAlign   = ContentAlignment.MiddleCenter;
                overflow.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;

                for (int i = totalItems - 1; i >= overflowIndex; i--)
                {
                    ToolStripItem item = items[i];
                    items.RemoveAt(i);
                    overflow.DropDown.Items.Insert(0, item);
                }

                CalculateOverflow(contextMenu, overflow.DropDownItems, maxHeight);

                if (overflow.DropDown.Items.Count > 0)
                {
                    items.Add(overflow);
                }
                else
                {
                    overflow.Dispose();
                }
            }
        }
Exemplo n.º 7
0
        private void reloadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripItemCollection macroMenuItems = macrosToolStripMenuItem.DropDownItems;

            while (macroMenuItems.Count > 2)
            {
                macroMenuItems.RemoveAt(macroMenuItems.Count - 1);
            }
            macroReload();
        }
Exemplo n.º 8
0
        void MdiWindowListItem_DropDownOpening(object sender, EventArgs e)
        {
            // ukloni separator ako je zadnji u listi
            ToolStripItemCollection items = menuStrip1.MdiWindowListItem.DropDownItems;

            if (items[items.Count - 1] is ToolStripSeparator)
            {
                items.RemoveAt(items.Count - 1);
            }
        }
Exemplo n.º 9
0
 public void deleteButton()
 {
     for (int i = Items.Count - 1; i >= 0; i--)
     {
         if (Items[i].Name.StartsWith(itemNamePart))
         {
             Items.RemoveAt(i);
         }
         //Items.Remove(item);
     }
 }
Exemplo n.º 10
0
        // A separator is automatically shown between the last window list menu item
        // you manually added at design-time and any dynamically added menu items for
        // MDI children. However, when all MDI children are closed, the separator
        // does not disappear. This event handler copes with it.
        private void mnWindow_DropDownOpening(object sender, EventArgs e)
        {
            // Hide separator if it is the last menu strip item in
            // the window list menu
            ToolStripItemCollection items =
                this.menuStrip1.MdiWindowListItem.DropDownItems;

            if (items[items.Count - 1] is ToolStripSeparator)
            {
                items.RemoveAt(items.Count - 1);
            }
        }
Exemplo n.º 11
0
        private void childWindowClosedHandler(ChildWindowBase window)
        {
            ToolStripItemCollection items = windowsMenu.DropDownItems;
            int elementCount = items.Count;

            for (int i = elementCount - 1; i >= 0; i--)
            {
                if (items[i].Tag == window)
                {
                    items.RemoveAt(i);
                }
            }
        }
Exemplo n.º 12
0
 private static void ClearMenu(ToolStripItemCollection items)
 {
     if (items.Count == 0)
     {
         return;
     }
     for (int i = items.Count - 1; i >= 0; i--)
     {
         if (items[i].Tag is Smmprog || items[i].Text == "´°¿Ú")
         {
             items.RemoveAt(i);
         }
     }
 }
Exemplo n.º 13
0
        private void ClearHelpers(ToolStripItemCollection dropdown, ToolStripItem tss, string prefix)
        {
            int i = dropdown.IndexOf(tss) + 1;

            while (true)
            {
                if (i >= dropdown.Count)
                {
                    break;
                }
                if (!dropdown[i].Name.StartsWith(prefix))
                {
                    break;
                }
                dropdown.RemoveAt(i);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Recursively configure appearance of label menu items
        /// </summary>
        /// <param name="items">Collection of menu items to process</param>
        private void SetupLabels(ToolStripItemCollection items)
        {
            for (int i = 0; i < items.Count; i++)
            {
                ToolStripItem tsi = items[i];
                if (tsi.Name.EndsWith("Label"))
                {
                    ToolStripLabel label = new ToolStripLabel(tsi.Text);
                    label.Font = new Font(tsi.Font, FontStyle.Underline | FontStyle.Bold);

                    items.RemoveAt(i);
                    items.Insert(i, label);
                }
                else if (tsi is ToolStripMenuItem && ((ToolStripMenuItem)tsi).HasDropDownItems)
                {
                    SetupLabels(((ToolStripMenuItem)tsi).DropDownItems);
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Nodes the selected.
        /// </summary>
        /// <param name="sender">The sender.</param>
        private void BuildContextMenu(Object sender)
        {
            //MessageBox.Show("BuildContextMenu");
            int __idx      = 0;
            int __savedpos = 0;

            try
            {
                ToolStripItemCollection __tsi = __ptv.ContextMenuStrip.Items;
                foreach (ToolStripItem __Item in __tsi)
                {
                    if (__Item.Text == LocaleHelper.GetString("LibraryDepot.Menu.Title"))
                    {
                        // removing menu
                        __tsi.Remove(__Item);

                        // removing separator
                        __tsi.RemoveAt(__idx);

                        // saving position for recreating treemenu
                        __savedpos = __idx;
                    }
                    __idx++;
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }

            ToolStripMenuItem tsmi = new ToolStripMenuItem(LocaleHelper.GetString("LibraryDepot.Menu.Title"), PluginBase.MainForm.FindImage("205"));

            BuildDirectoryMenu(tsmi, __LibraryPath);
            BuildFileMenu(tsmi, __LibraryPath);

            (sender as Control).ContextMenuStrip.Items.Insert(__savedpos, tsmi);
            (sender as Control).ContextMenuStrip.Items.Insert(__savedpos + 1, new ToolStripSeparator());

            /*if (settingObject.CheckTimer != TimerCheckInterval.Never)
             * {
             *      __timer.Start();
             * }*/
        }
Exemplo n.º 16
0
        public static int CreateEncodingsMenuItems(ToolStripItemCollection root,
                                                   Func <string> getText, Action <string> setText,
                                                   List <EncodingItemData> encodingsList)
        {
            GetText = getText;
            SetText = setText;
            //m_RichTextBoxSrc = richSrc;
            //m_RichTextBoxDst = richDst;

            ArrayList vEncodingMenus = new ArrayList();

            for (int i = 0; i < encodingsList.Count; i++)
            {
                EncodingItemData itm = encodingsList[i];
                if (!itm.ShowInMenu)
                {
                    continue;
                }

                ToolStripItem x = new ToolStripMenuItem(itm.EncodingName);
                x.Tag    = itm;
                x.Click += MenuItem_Encoding_Click;

                vEncodingMenus.Add(x);
            }            //end for

            //leave first 2 items
            while (root.Count > 2)
            {
                root.RemoveAt(root.Count - 1);
            }

            if (vEncodingMenus.Count == 0)
            {
                return(0);
            }

            root.AddRange((ToolStripItem[])vEncodingMenus.ToArray(typeof(ToolStripItem)));

            return(root.Count);
        }        //end CreateEncodingsMenuItems
Exemplo n.º 17
0
        public static void ClearAndDispose(this ToolStripItemCollection items,
                                           int startIndex, int endIndex)
        {
            if (items == null)
            {
                throw new ArgumentNullException("items");
            }
            if (startIndex < 0 || startIndex > items.Count)
            {
                throw new ArgumentOutOfRangeException("startIndex");
            }
            if (endIndex < startIndex || endIndex > items.Count)
            {
                throw new ArgumentOutOfRangeException("endIndex");
            }

            for (int i = endIndex - 1; i >= startIndex; i--)
            {
                ToolStripItem item = items[i];
                items.RemoveAt(i);
                item.Dispose();
            }
        }
Exemplo n.º 18
0
        private void multiExplorerControl_PropertyChanged(object sender, EventArgs e)
        {
            XmlNode listCol = null;

            string []         folderPath;
            ToolStripMenuItem folderItem;

            WssLists.Lists       lists    = new roxUp.WssLists.Lists();
            WssSiteData.SiteData siteData = new roxUp.WssSiteData.SiteData();
            WssLists.GetListCollectionCompletedEventHandler  onLists   = null;
            WssSiteData.EnumerateFolderCompletedEventHandler onFolders = null;
            onFolders = delegate(object tmp2, WssSiteData.EnumerateFolderCompletedEventArgs folderArgs) {
                WebException        webEx = folderArgs.Error as WebException;
                HttpWebResponse     resp;
                Cookie              cookie;
                CookieCollection    cookies;
                DialogResult        prompt;
                WssAuth.LoginResult authResult;
                int    pos;
                string userState = folderArgs.UserState as string, pathPrefix = string.Empty;
                ToolStripItemCollection    items = statusFolderItem.DropDownItems;
                List <WssSiteData._sFPUrl> folders = new List <roxUp.WssSiteData._sFPUrl> ();
                statusFolderItem.Enabled = multiExplorerControl.allowFolderChange && !multiExplorerControl.isUploadBusy;
                if ((!string.IsNullOrEmpty(userState)) && ((folderPath = userState.Split(new char [] { '/' }, StringSplitOptions.RemoveEmptyEntries)) != null) && (folderPath.Length > 0))
                {
                    for (int i = 0; i < folderPath.Length; i++)
                    {
                        foreach (ToolStripItem item in items)
                        {
                            if (((folderItem = item as ToolStripMenuItem) != null) && (!string.IsNullOrEmpty(item.Tag + "")) && item.Tag.ToString().Equals(pathPrefix + folderPath [i]))
                            {
                                folderItem.Checked = multiExplorerControl.FolderName.StartsWith(item.Tag.ToString());
                                items = folderItem.DropDownItems;
                                folderItem.Enabled = true;
                                pathPrefix         = pathPrefix + folderPath [i] + '/';
                                break;
                            }
                        }
                    }
                }
                if (items != statusFolderItem.DropDownItems)
                {
                    items.Clear();
                }
                else
                {
                    while (items.Count > 2)
                    {
                        items.RemoveAt(2);
                    }
                }
                if ((webEx != null) && ((resp = webEx.Response as HttpWebResponse) != null) && ((resp.StatusCode == HttpStatusCode.Unauthorized) || (resp.StatusCode == HttpStatusCode.ProxyAuthenticationRequired) || (resp.StatusCode == HttpStatusCode.Forbidden)))
                {
                    multiExplorerControl.lastCookie = null;
                    using (LoginForm loginForm = new LoginForm(multiExplorerControl.allowSavePassword, multiExplorerControl.isUserLoginStored)) {
                        if ((!multiExplorerControl.isFormsAuth) && string.IsNullOrEmpty(multiExplorerControl.logonPass) && string.IsNullOrEmpty(multiExplorerControl.logonDomain) && string.IsNullOrEmpty(multiExplorerControl.logonUser))
                        {
                            multiExplorerControl.logonDomain = Environment.UserDomainName;
                            multiExplorerControl.logonUser   = Environment.UserName;
                        }
                        loginForm.userNameTextBox.Text = (string.IsNullOrEmpty(multiExplorerControl.logonDomain) ? multiExplorerControl.logonUser : (multiExplorerControl.logonDomain + '\\' + multiExplorerControl.logonUser));
                        loginForm.passwordTextBox.Text = multiExplorerControl.logonPass;
                        prompt = ((multiExplorerControl.isFormsAuth && multiExplorerControl.firstAttempt && (!string.IsNullOrEmpty(multiExplorerControl.logonPass)) && (!string.IsNullOrEmpty(multiExplorerControl.logonUser))) ? DialogResult.OK : loginForm.ShowDialog(this));
                        multiExplorerControl.firstAttempt = false;
                        if (prompt == DialogResult.OK)
                        {
                            multiExplorerControl.logonDomain = (((pos = loginForm.userNameTextBox.Text.IndexOf('\\')) > 0) ? loginForm.userNameTextBox.Text.Substring(0, pos) : string.Empty);
                            multiExplorerControl.logonUser   = loginForm.userNameTextBox.Text.Substring((pos >= 0) ? (pos + 1) : 0);
                            multiExplorerControl.logonPass   = loginForm.passwordTextBox.Text;
                            multiExplorerControl.SaveOrForgetUserData(loginForm.checkBox.Checked);
                            if (multiExplorerControl.isFormsAuth)
                            {
                                using (WssAuth.Authentication auth = new WssAuth.Authentication())
                                    try {
                                        auth.Url             = multiExplorerControl.Url.Replace("_layouts/roxority_UploadZen/Files.asmx", "_vti_bin/Authentication.asmx");
                                        auth.CookieContainer = new CookieContainer();
                                        if (((cookie = multiExplorerControl.lastCookie) != null) || (((authResult = auth.Login(multiExplorerControl.LogonUser, multiExplorerControl.LogonPass)) != null) && (authResult.ErrorCode == WssAuth.LoginErrorCode.NoError) && (!string.IsNullOrEmpty(authResult.CookieName)) && ((cookies = auth.CookieContainer.GetCookies(new Uri(auth.Url))) != null) && ((cookie = cookies [authResult.CookieName]) != null)))
                                        {
                                            multiExplorerControl.lastCookie = cookie;
                                            EnsureCookie(siteData);
                                        }
                                        else
                                        {
                                            multiExplorerControl.lastCookie = null;
                                            if (authResult == null)
                                            {
                                                throw new UnauthorizedAccessException();
                                            }
                                            else if (authResult.ErrorCode == roxUp.WssAuthentication.LoginErrorCode.NotInFormsAuthenticationMode)
                                            {
                                                multiExplorerControl.isFormsAuth = false;
                                                lists.PreAuthenticate            = siteData.PreAuthenticate = true;
                                                lists.Credentials = siteData.Credentials = ((string.IsNullOrEmpty(multiExplorerControl.LogonUser) && !multiExplorerControl.forceLogin) ? (CredentialCache.DefaultNetworkCredentials) : (string.IsNullOrEmpty(multiExplorerControl.LogonDomain) ? new NetworkCredential(multiExplorerControl.LogonUser, multiExplorerControl.LogonPass) : new NetworkCredential(multiExplorerControl.LogonUser, multiExplorerControl.LogonPass, multiExplorerControl.LogonDomain)));
                                            }
                                            else if (authResult.ErrorCode != roxUp.WssAuthentication.LoginErrorCode.NoError)
                                            {
                                                throw new UnauthorizedAccessException(res.AuthError_PasswordNotMatch);
                                            }
                                        }
                                    } catch (Exception ex) {
                                        multiExplorerControl.lastCookie = null;
                                        MessageBox.Show(this, ex.Message, ex.GetType().FullName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                            }
                            else
                            {
                                lists.PreAuthenticate = siteData.PreAuthenticate = true;
                                lists.Credentials     = siteData.Credentials = ((string.IsNullOrEmpty(multiExplorerControl.LogonUser) && !multiExplorerControl.forceLogin) ? (CredentialCache.DefaultNetworkCredentials) : (string.IsNullOrEmpty(multiExplorerControl.LogonDomain) ? new NetworkCredential(multiExplorerControl.LogonUser, multiExplorerControl.LogonPass) : new NetworkCredential(multiExplorerControl.LogonUser, multiExplorerControl.LogonPass, multiExplorerControl.LogonDomain)));
                            }
                            siteData.EnumerateFolderAsync(folderArgs.UserState.ToString());
                        }
                        else
                        {
                            siteData.EnumerateFolderCompleted -= onFolders;
                            siteData.Dispose();
                            siteData = null;
                        }
                    }
                    multiExplorerControl.UpdateUserItem();
                }
                else if (folderArgs.Error != null)
                {
                    siteData.EnumerateFolderCompleted -= onFolders;
                    siteData.Dispose();
                    siteData = null;
                    if (MessageBox.Show(this, folderArgs.Error.Message, Application.ProductName, (lists != null) ? MessageBoxButtons.RetryCancel : MessageBoxButtons.OK, MessageBoxIcon.Warning) == DialogResult.Retry)
                    {
                        lists.GetListCollectionCompleted += onLists;
                        lists.GetListCollectionAsync();
                    }
                }
                else if ((folderArgs.Result == 0) && (folderArgs.vUrls != null) && (folderArgs.vUrls.Length > 0))
                {
                    folders.AddRange(folderArgs.vUrls);
                    folders.RemoveAll(delegate(WssSiteData._sFPUrl sfpUrl) {
                        return((!sfpUrl.IsFolder) || sfpUrl.Url.Substring(sfpUrl.Url.IndexOf('/') + 1).Equals("Forms"));
                    });
                    folders.Sort(delegate(WssSiteData._sFPUrl one, WssSiteData._sFPUrl two) {
                        return(one.Url.CompareTo(two.Url));
                    });
                    foreach (WssSiteData._sFPUrl sfpUrl in folders)
                    {
                        folderItem         = items.Add(sfpUrl.Url.Substring(sfpUrl.Url.LastIndexOf('/') + 1), statusFolderItem.Image, folderMenuItem_Click) as ToolStripMenuItem;
                        folderItem.Enabled = false;
                        folderItem.Tag     = sfpUrl.Url.Substring(sfpUrl.Url.IndexOf('/') + 1);
                        siteData.EnumerateFolderAsync(sfpUrl.Url, folderItem.Tag + "");
                    }
                }
                statusFolderItem.DropDownItems [1].Visible = ((folders.Count > 0) || (!string.IsNullOrEmpty(pathPrefix)));
            };
            onLists = delegate(object tmp, WssLists.GetListCollectionCompletedEventArgs args) {
                WebException               webEx = args.Error as WebException;
                HttpWebResponse            resp;
                ToolStripMenuItem          item;
                Cookie                     cookie;
                CookieCollection           cookies;
                DialogResult               prompt;
                WssSiteData._sListMetadata listMetaData = null;
                WssSiteData._sProperty []  listProps    = null;
                WssAuth.LoginResult        authResult;
                int  pos, listTemp;
                uint metaResult;
                if ((webEx != null) && ((resp = webEx.Response as HttpWebResponse) != null) && ((resp.StatusCode == HttpStatusCode.Unauthorized) || (resp.StatusCode == HttpStatusCode.ProxyAuthenticationRequired) || (resp.StatusCode == HttpStatusCode.Forbidden)))
                {
                    multiExplorerControl.lastCookie = null;
                    using (LoginForm loginForm = new LoginForm(multiExplorerControl.allowSavePassword, multiExplorerControl.isUserLoginStored)) {
                        if ((!multiExplorerControl.isFormsAuth) && string.IsNullOrEmpty(multiExplorerControl.logonPass) && string.IsNullOrEmpty(multiExplorerControl.logonDomain) && string.IsNullOrEmpty(multiExplorerControl.logonUser))
                        {
                            multiExplorerControl.logonDomain = Environment.UserDomainName;
                            multiExplorerControl.logonUser   = Environment.UserName;
                        }
                        loginForm.userNameTextBox.Text = (string.IsNullOrEmpty(multiExplorerControl.logonDomain) ? multiExplorerControl.logonUser : (multiExplorerControl.logonDomain + '\\' + multiExplorerControl.logonUser));
                        loginForm.passwordTextBox.Text = multiExplorerControl.logonPass;
                        prompt = ((multiExplorerControl.isFormsAuth && multiExplorerControl.firstAttempt && (!string.IsNullOrEmpty(multiExplorerControl.logonPass)) && (!string.IsNullOrEmpty(multiExplorerControl.logonUser))) ? DialogResult.OK : loginForm.ShowDialog(this));
                        multiExplorerControl.firstAttempt = false;
                        if (prompt == DialogResult.OK)
                        {
                            multiExplorerControl.logonDomain = (((pos = loginForm.userNameTextBox.Text.IndexOf('\\')) > 0) ? loginForm.userNameTextBox.Text.Substring(0, pos) : string.Empty);
                            multiExplorerControl.logonUser   = loginForm.userNameTextBox.Text.Substring((pos >= 0) ? (pos + 1) : 0);
                            multiExplorerControl.logonPass   = loginForm.passwordTextBox.Text;
                            multiExplorerControl.SaveOrForgetUserData(loginForm.checkBox.Checked);
                            if (multiExplorerControl.isFormsAuth)
                            {
                                using (WssAuth.Authentication auth = new WssAuth.Authentication())
                                    try {
                                        auth.Url             = multiExplorerControl.Url.Replace("_layouts/roxority_UploadZen/Files.asmx", "_vti_bin/Authentication.asmx");
                                        auth.CookieContainer = new CookieContainer();
                                        if (((cookie = multiExplorerControl.lastCookie) != null) || (((authResult = auth.Login(multiExplorerControl.LogonUser, multiExplorerControl.LogonPass)) != null) && (authResult.ErrorCode == WssAuth.LoginErrorCode.NoError) && (!string.IsNullOrEmpty(authResult.CookieName)) && ((cookies = auth.CookieContainer.GetCookies(new Uri(auth.Url))) != null) && ((cookie = cookies [authResult.CookieName]) != null)))
                                        {
                                            multiExplorerControl.lastCookie = cookie;
                                            EnsureCookie(lists, siteData);
                                        }
                                        else
                                        {
                                            multiExplorerControl.lastCookie = null;
                                            if (authResult == null)
                                            {
                                                throw new UnauthorizedAccessException();
                                            }
                                            else if (authResult.ErrorCode == roxUp.WssAuthentication.LoginErrorCode.NotInFormsAuthenticationMode)
                                            {
                                                multiExplorerControl.isFormsAuth = false;
                                                lists.PreAuthenticate            = siteData.PreAuthenticate = true;
                                                lists.Credentials = siteData.Credentials = ((string.IsNullOrEmpty(multiExplorerControl.LogonUser) && !multiExplorerControl.forceLogin) ? (CredentialCache.DefaultNetworkCredentials) : (string.IsNullOrEmpty(multiExplorerControl.LogonDomain) ? new NetworkCredential(multiExplorerControl.LogonUser, multiExplorerControl.LogonPass) : new NetworkCredential(multiExplorerControl.LogonUser, multiExplorerControl.LogonPass, multiExplorerControl.LogonDomain)));
                                            }
                                            else if (authResult.ErrorCode != roxUp.WssAuthentication.LoginErrorCode.NoError)
                                            {
                                                throw new UnauthorizedAccessException(res.AuthError_PasswordNotMatch);
                                            }
                                        }
                                    } catch (Exception ex) {
                                        multiExplorerControl.lastCookie = null;
                                        MessageBox.Show(this, ex.Message, ex.GetType().FullName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                            }
                            else
                            {
                                siteData.PreAuthenticate = lists.PreAuthenticate = true;
                                siteData.Credentials     = lists.Credentials = ((string.IsNullOrEmpty(multiExplorerControl.LogonUser) && !multiExplorerControl.forceLogin) ? (CredentialCache.DefaultNetworkCredentials) : (string.IsNullOrEmpty(multiExplorerControl.LogonDomain) ? new NetworkCredential(multiExplorerControl.LogonUser, multiExplorerControl.LogonPass) : new NetworkCredential(multiExplorerControl.LogonUser, multiExplorerControl.LogonPass, multiExplorerControl.LogonDomain)));
                            }
                            lists.GetListCollectionAsync();
                        }
                        else
                        {
                            lists.GetListCollectionCompleted -= onLists;
                            lists.Dispose();
                            lists = null;
                        }
                    }
                    multiExplorerControl.UpdateUserItem();
                }
                else if (args.Error != null)
                {
                    if (MessageBox.Show(this, args.Error.Message, Application.ProductName, MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning) == DialogResult.Retry)
                    {
                        lists.GetListCollectionAsync();
                    }
                    else
                    {
                        lists.GetListCollectionCompleted -= onLists;
                        lists.Dispose();
                        lists = null;
                    }
                }
                else
                {
                    try {
                        listCol = args.Result;
                    } catch {
                        listCol = null;
                    } finally {
                        lists.GetListCollectionCompleted -= onLists;
                        lists.Dispose();
                        lists = null;
                    }
                    if (listCol != null)
                    {
                        statusListItem.DropDownItems.Clear();
                        foreach (XmlNode listNode in listCol.ChildNodes)
                        {
                            if (!string.IsNullOrEmpty(listNode.Attributes ["DefaultViewUrl"].Value) && ((Array.IndexOf <int> (docLibTemplates, listTemp = int.Parse(listNode.Attributes ["ServerTemplate"].Value)) >= 0) || !string.IsNullOrEmpty(listNode.Attributes ["DocTemplateUrl"].Value)))
                            {
                                item      = statusListItem.DropDownItems.Add(listNode.Attributes ["Title"].Value, null, listMenuItem_Click) as ToolStripMenuItem;
                                item.Name = listNode.Attributes ["ID"].Value;
                                item.Tag  = listNode.Attributes ["DefaultViewUrl"].Value.Substring(listNode.Attributes ["WebFullUrl"].Value.Length);
                                if (item.Tag.ToString().Contains("/") && ((item.Tag = item.Tag.ToString().Substring(0, item.Tag.ToString().LastIndexOf('/')).Trim('/')).ToString().EndsWith("/Forms")))
                                {
                                    item.Tag = item.Tag.ToString().Substring(0, item.Tag.ToString().LastIndexOf('/'));
                                }
                                if (item.Checked = ((statusSiteItem.ToolTipText + '/' + listNode.Attributes ["DefaultViewUrl"].Value.Substring(listNode.Attributes ["WebFullUrl"].Value.Length).Trim('/')).ToLowerInvariant().StartsWith((statusSiteItem.ToolTipText + '/' + multiExplorerControl.ListName).ToLowerInvariant())))
                                {
                                    if ((statusListItem.Text = item.Text).Equals(statusListItem.ToolTipText = (statusListItem.Tag = item.Tag) + ""))
                                    {
                                        statusListItem.ToolTipText = string.Empty;
                                    }
                                    statusListItem.Name = item.Name;
                                    multiExplorerControl.SetFilterByTemplate(listNode.Attributes ["ServerTemplate"].Value);
                                }
                            }
                        }
                        statusFolderItem.DropDown.Close(ToolStripDropDownCloseReason.CloseCalled);
                        if (multiExplorerControl.allowFolderChange)
                        {
                            siteData.EnumerateFolderCompleted += onFolders;
                            siteData.EnumerateFolderAsync(statusListItem.Tag + "", string.Empty);
                        }
                        if (lastListName != multiExplorerControl.ListName)
                        {
                            multiExplorerControl.propertyGrid.SelectedObject = null;
                            multiExplorerControl.metaListView.Items.Clear();
                            listMetaData = null;
                            listProps    = null;
                            lastListName = multiExplorerControl.ListName;
                            Application.DoEvents();
                            try {
                                metaResult = siteData.GetList(statusListItem.Name, out listMetaData, out listProps);
                            } catch (Exception ex) {
                                SoapException soapEx = ex as SoapException;
                                MessageBox.Show(this, ex.Message + (((soapEx == null) || (soapEx.Detail == null)) ? string.Empty : ("\r\n\r\n" + soapEx.Detail.OuterXml)), ex.GetType().FullName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                            Application.DoEvents();
                            if (listProps != null)
                            {
                                foreach (WssSiteData._sProperty prop in listProps)
                                {
                                    if ((Array.IndexOf <string> (suppressedMetaNames, prop.Name) < 0) && (Array.IndexOf <string> (suppressedMetaTypes, prop.Type) < 0))
                                    {
                                        multiExplorerControl.metaListView.Items.Add(new MetaDataWrap(prop).ToListViewItem());
                                    }
                                }
                            }
                            multiExplorerControl.metaListView.AutoResizeColumns((multiExplorerControl.metaListView.Items.Count > 0) ? ColumnHeaderAutoResizeStyle.ColumnContent : ColumnHeaderAutoResizeStyle.HeaderSize);
                            multiExplorerControl.metaListView.AutoResizeColumn(2, ColumnHeaderAutoResizeStyle.HeaderSize);
                        }
                    }
                    statusListItem.Enabled = multiExplorerControl.allowListChange && !multiExplorerControl.isUploadBusy;
                }
            };
            statusFolderItem.Enabled = statusListItem.Enabled = false;
            statusListItem.DropDownItems.Clear();
            statusFolderItem.DropDownItems.Clear();
            statusFolderItem.DropDownItems.Add(folderItem = new ToolStripMenuItem(res.Root, statusFolderItem.Image, folderMenuItem_Click));
            folderItem.Checked = string.IsNullOrEmpty(multiExplorerControl.FolderName);
            folderItem.Tag     = string.Empty;
            statusFolderItem.DropDownItems.Add(new ToolStripSeparator());
            statusListItem.Text        = multiExplorerControl.ListName;
            statusFolderItem.Text      = string.IsNullOrEmpty(multiExplorerControl.FolderName) ? res.Root : multiExplorerControl.FolderName;
            statusSiteItem.ToolTipText = multiExplorerControl.Url.Replace("/_layouts/roxority_UploadZen/Files.asmx", string.Empty);
            statusSiteItem.Text        = (string.IsNullOrEmpty(siteTitle) ? statusSiteItem.ToolTipText.Substring(statusSiteItem.ToolTipText.IndexOf("://") + "://".Length) : siteTitle);
            lists.Url    = statusSiteItem.ToolTipText.TrimEnd('/') + "/_vti_bin/Lists.asmx";
            siteData.Url = statusSiteItem.ToolTipText.TrimEnd('/') + "/_vti_bin/SiteData.asmx";
            if (!multiExplorerControl.isFormsAuth)
            {
                siteData.PreAuthenticate = lists.PreAuthenticate = true;
                siteData.Credentials     = lists.Credentials = ((string.IsNullOrEmpty(multiExplorerControl.LogonUser) && !multiExplorerControl.forceLogin) ? CredentialCache.DefaultNetworkCredentials : (string.IsNullOrEmpty(multiExplorerControl.LogonDomain) ? new NetworkCredential(multiExplorerControl.LogonUser, multiExplorerControl.LogonPass) : new NetworkCredential(multiExplorerControl.LogonUser, multiExplorerControl.LogonPass, multiExplorerControl.LogonDomain)));
            }
            else
            {
                EnsureCookie(lists, siteData);
            }
            if (multiExplorerControl.allowListChange || multiExplorerControl.allowFolderChange)
            {
                lists.GetListCollectionCompleted += onLists;
                lists.GetListCollectionAsync();
            }
            multiExplorerControl.UpdateUserItem();
        }
Exemplo n.º 19
0
 public void RemoveAt(int index)
 {
     collection.RemoveAt(index);
 }