public bool FlushSendBuffer()
        {
            try
            {
                if (currentBufferIndex > 0)
                {
                    PushCurrentBuffer();
                }

                if (cmdBuffer.Count > 0)
                {
                    if (!Env.IsMono && sslStream == null)
                    {
                        socket.Send(cmdBuffer); //Optimized for Windows
                    }
                    else
                    {
                        //Sendling IList<ArraySegment> Throws 'Message to Large' SocketException in Mono
                        foreach (var segment in cmdBuffer)
                        {
                            var buffer = segment.Array;
                            if (sslStream == null)
                            {
                                socket.Send(buffer, segment.Offset, segment.Count, SocketFlags.None);
                            }
                            else
                            {
                                sslStream.Write(buffer, segment.Offset, segment.Count);
                            }
                        }
                    }
                }
                ResetSendBuffer();
            }
            catch (IOException ex)  // several stream commands wrap SocketException in IOException
            {
                var socketEx = ex.InnerException as SocketException;
                if (socketEx == null)
                {
                    throw;
                }

                cmdBuffer.Clear();
                return(HandleSocketException(socketEx));
            }
            catch (SocketException ex)
            {
                cmdBuffer.Clear();
                return(HandleSocketException(ex));
            }
            return(true);
        }
        private void CleanUpRecentList()
        {
            foreach (var menuItem in RecentItems)
            {
                menuItem.Click -= RecentDataDirectoryClicked;
                Instance.MenuFileOpenRecently.Items.Remove(menuItem);
            }

            List <string> ItemsForRemoval = new List <string>();

            for (int i = 0; i < AnimationEditor.Classes.Settings.Default.RecentFiles.Count; i++)
            {
                if (File.Exists(AnimationEditor.Classes.Settings.Default.RecentFiles[i].FilePath))
                {
                    continue;
                }
                else
                {
                    ItemsForRemoval.Add(AnimationEditor.Classes.Settings.Default.RecentFiles[i].FilePath);
                }
            }
            foreach (string item in ItemsForRemoval)
            {
                AnimationEditor.Classes.Settings.Default.RecentFiles.RemoveAll(x => x.FilePath == item);
            }

            RecentItems.Clear();
        }
示例#3
0
        private void CleanUpRecentList()
        {
            foreach (var menuItem in RecentItems)
            {
                menuItem.Click -= RecentDataDirectoryClicked;
                Instance.MenuFileOpenRecently.Items.Remove(menuItem);
            }

            List <string> ItemsForRemoval = new List <string>();

            for (int i = 0; i < Properties.Settings.Default.RecentFiles.Count; i++)
            {
                if (File.Exists(Properties.Settings.Default.RecentFiles[i]))
                {
                    continue;
                }
                else
                {
                    ItemsForRemoval.Add(Properties.Settings.Default.RecentFiles[i]);
                }
            }
            foreach (string item in ItemsForRemoval)
            {
                Properties.Settings.Default.RecentFiles.Remove(item);
            }

            RecentItems.Clear();
        }
        private void CleanUpWorkspaceList()
        {
            foreach (var menuItem in WorkspaceItems)
            {
                menuItem.Click -= WorkspaceFolderClicked;
                Instance.MenuFileOpenFromWorkspace.Items.Remove(menuItem);
            }

            WorkspaceItems.Clear();
        }
        /**
         * Initialize a polygon by taking ownership of the given loops and clearing
         * the given list. This method figures out the loop nesting hierarchy and then
         * reorders the loops by following a preorder traversal. This implies that
         * each loop is immediately followed by its descendants in the nesting
         * hierarchy. (See also getParent and getLastDescendant.)
         */

        public void Init(System.Collections.Generic.IList <S2Loop> loops)
        {
            // assert isValid(loops);
            // assert (this.loops.isEmpty());

            //Dictionary<S2Loop, List<S2Loop>> loopMap =new Dictionary<S2Loop, List<S2Loop>>();
            // Note: We're using C5's HashDictionary because SCG's Dictionary<,> does not allow
            // NULL keys
            var loopMap = new Dictionary <NullObject <S2Loop>, List <S2Loop> >();

            // Yes, a null key is valid. It is used here to refer to the root of the
            // loopMap
            loopMap[null] = new List <S2Loop>();

            foreach (var loop in loops)
            {
                InsertLoop(loop, null, loopMap);
                _numVertices += loop.NumVertices;
            }
            loops.Clear();

            // Sort all of the lists of loops; in this way we guarantee a total ordering
            // on loops in the polygon. Loops will be sorted by their natural ordering,
            // while also preserving the requirement that each loop is immediately
            // followed by its descendants in the nesting hierarchy.
            //
            // TODO(andriy): as per kirilll in CL 18750833 code review comments:
            // This should work for now, but I think it's possible to guarantee the
            // correct order inside insertLoop by searching for the correct position in
            // the children list before inserting.
            SortValueLoops(loopMap);

            // Reorder the loops in depth-first traversal order.
            // Starting at null == starting at the root
            InitLoop(null, -1, loopMap);

            // TODO(dbeaumont): Add tests or preconditions for these asserts (here and elesewhere).
            // forall i != j : containsChild(loop(i), loop(j), loopMap) == loop(i).containsNested(loop(j)));

            // Compute the bounding rectangle of the entire polygon.
            _hasHoles = false;
            _bound    = S2LatLngRect.Empty;
            for (var i = 0; i < NumLoops; ++i)
            {
                if (Loop(i).Sign < 0)
                {
                    _hasHoles = true;
                }
                else
                {
                    _bound = _bound.Union(Loop(i).RectBound);
                }
            }
        }
示例#6
0
        public void Clear()
        {
            int nCount = list.Count;

            list.Clear();
            if (nCount > 0)
            {
                System.ComponentModel.ListChangedEventArgs e = new System.ComponentModel.ListChangedEventArgs(System.ComponentModel.ListChangedType.Reset, -1);
                OnListChanged(e);
            }
        }
示例#7
0
        private void CmdProperty_PropertyTableSelectionChangedEvent(DataRow dr)
        {
            try
            {
                if (regexDataList != null)
                {
                    regexDataList.Clear();
                }
                colName = "";
                fids    = null;
                if (dr == null)
                {
                    return;
                }

                colName = (dr["F"] as IFieldInfo).Name;
                DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer;
                if (dffc == null)
                {
                    return;
                }
                HashMap hm = SelectCollection.Instance().GetSelectGeometrys();
                if (hm != null && hm.Count == 1)
                {
                    IRowBufferCollection rowBufferCollection = hm[dffc] as IRowBufferCollection;
                    if (rowBufferCollection != null)
                    {
                        List <int> listFids = SelectCollection.Instance().GetOIDList(rowBufferCollection);
                        if (listFids != null)
                        {
                            fids = listFids.ToArray <int>();
                            if (dr["FV"] == null)
                            {
                                regexDataList = null;
                            }
                            {
                                if (regexDataList == null)
                                {
                                    regexDataList = new List <RegexDataStruct>();
                                }
                                RegexDataStruct rds = new RegexDataStruct(dr["FV"].ToString(), CharactorType.ConstKey);
                                regexDataList.Add(rds);
                            }
                            UpdateDatabase();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        /**
         * Assembles the given edges into as many non-crossing loops as possible. When
         * there is a choice about how to assemble the loops, then CCW loops are
         * preferred. Returns true if all edges were assembled. If "unused_edges" is
         * not NULL, it is initialized to the set of edges that could not be assembled
         * into loops.
         *
         *  Note that if xor_edges() is false and duplicate edge pairs may be present,
         * then undirected_edges() should be specified unless all loops can be
         * assembled in a counter-clockwise direction. Otherwise this method may not
         * be able to assemble all loops due to its preference for CCW loops.
         *
         * This method resets the S2PolygonBuilder state so that it can be reused.
         */

        public bool AssembleLoops(System.Collections.Generic.IList <S2Loop> loops, System.Collections.Generic.IList <S2Edge> unusedEdges)
        {
            if (_options.MergeDistance.Radians > 0)
            {
                MergeVertices();
            }

            var dummyUnusedEdges = new List <S2Edge>();

            if (unusedEdges == null)
            {
                unusedEdges = dummyUnusedEdges;
            }

            // We repeatedly choose an arbitrary edge and attempt to assemble a loop
            // starting from that edge. (This is always possible unless the input
            // includes extra edges that are not part of any loop.)

            unusedEdges.Clear();
            while (_edges.Any())
            {
                //Map.Entry<S2Point, Multiset<S2Point>> edge = edges.entrySet().iterator().next();
                var edge = _edges.First();

                var v0 = edge.Key;
                var v1 = edge.Value.First();

                var loop = AssembleLoop(v0, v1, unusedEdges);
                if (loop == null)
                {
                    continue;
                }

                // In the case of undirected edges, we may have assembled a clockwise
                // loop while trying to assemble a CCW loop. To fix this, we assemble
                // a new loop starting with an arbitrary edge in the reverse direction.
                // This is guaranteed to assemble a loop that is interior to the previous
                // one and will therefore eventually terminate.

                while (_options.UndirectedEdges && !loop.IsNormalized)
                {
                    loop = AssembleLoop(loop.Vertex(1), loop.Vertex(0), unusedEdges);
                }
                loops.Add(loop);
                EraseLoop(loop, loop.NumVertices);
            }
            return(unusedEdges.Count == 0);
        }
示例#9
0
        protected void DoCallback()
        {
            base.Response.Clear();
            base.Response.ContentType = "application/json";
            string text = base.Request.QueryString["action"];

            if (text.Equals("getPrepareData"))
            {
                int typeId = int.Parse(base.Request.QueryString["typeId"]);
                System.Collections.Generic.IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(typeId);
                System.Data.DataTable dataTable = ProductTypeHelper.GetBrandCategoriesByTypeId(typeId);
                if (dataTable.Rows.Count == 0)
                {
                    dataTable = ControlProvider.Instance().GetBrandCategories();
                }
                base.Response.Write(this.GenerateJsonString(attributes, dataTable));
                attributes.Clear();
            }
            else
            {
                if (text.Equals("getMemberGradeList"))
                {
                    System.Collections.Generic.IList <MemberGradeInfo> memberGrades = MemberHelper.GetMemberGrades();
                    if (memberGrades == null || memberGrades.Count == 0)
                    {
                        base.Response.Write("{\"Status\":\"0\"}");
                    }
                    else
                    {
                        System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                        stringBuilder.Append("{\"Status\":\"OK\",\"MemberGrades\":[");
                        foreach (MemberGradeInfo current in memberGrades)
                        {
                            stringBuilder.Append("{");
                            stringBuilder.AppendFormat("\"GradeId\":\"{0}\",", current.GradeId);
                            stringBuilder.AppendFormat("\"Name\":\"{0}\",", current.Name);
                            stringBuilder.AppendFormat("\"Discount\":\"{0}\"", current.Discount);
                            stringBuilder.Append("},");
                        }
                        stringBuilder.Remove(stringBuilder.Length - 1, 1);
                        stringBuilder.Append("]}");
                        base.Response.Write(stringBuilder.ToString());
                    }
                }
            }
            base.Response.End();
        }
示例#10
0
        private void BindList(int skip)
        {
            if (this.rp_guest != null)
            {
                System.Collections.Generic.IList <int> browedProductList = BrowsedProductQueue.GetBrowedProductList((skip * this.maxNum) + this.MaxNum);

                int browedListCount = browedProductList.Count;
                if (browedListCount > (skip * this.maxNum) + this.MaxNum)
                {
                    int isRemove = browedListCount - this.maxNum;
                    while (isRemove > 0)
                    {
                        isRemove--;
                        browedProductList.RemoveAt(0);
                    }
                }
                else
                {
                    browedProductList.Clear();
                }
                //DataTable table = ProductBrowser.GetSuggestProductsProducts(browedProductList, 6);
                DataTable table = ProductBrowser.GetVistiedProducts(browedProductList);
                if (table != null)
                {
                    if (table.Rows.Count < this.maxNum)
                    {
                        DataTable dt = ProductBrowser.GetVistiedProducts(this.MaxNum - table.Rows.Count, skip * this.maxNum + 1, skip * this.maxNum + 1 + this.MaxNum);
                        TableToTable(table, dt);
                    }
                }
                else
                {
                    table = ProductBrowser.GetVistiedProducts(this.MaxNum, skip * this.maxNum + 1, skip * this.maxNum + 1 + this.MaxNum);
                }

                if (table.Rows.Count < 5)
                {
                    this.rp_guest.DataSource = null;
                    this.rp_guest.DataBind();
                    return;
                }
                this.rp_guest.DataSource = table;
                this.rp_guest.DataBind();
            }
        }