예제 #1
0
 /// <summary>
 /// 加入join连接
 /// </summary>
 /// <param name="join"></param>
 /// <param name="table1"></param>
 /// <param name="table2"></param>
 /// <param name="joinfields"></param>
 public DataBaseAction AddJoin(ViewJoinEnum join, string table1, string table2, List <QueryField> joinfields)
 {
     if (ViewList == null)
     {
         ViewList = new List <ViewHelper>();
     }
     foreach (var item in ViewList)
     {
         if (item.TableName1 != table1 || item.TableName2 != table2)
         {
             continue;
         }
         item.Joinfields.AddRange(joinfields);
         return(this);
     }
     ViewList.Add(new ViewHelper()
     {
         Join       = join,
         TableName1 = table1,
         TableName2 = table2,
         Joinfields = joinfields
     });
     return(this);
 }
예제 #2
0
        /// <summary>
        /// Discover the preferred size of the element.
        /// </summary>
        /// <param name="context">Layout context.</param>
        public override Size GetPreferredSize(ViewLayoutContext context)
        {
            // Sync child elements to the current group items
            SyncChildrenToRibbonGroupItems();

            // Clear down the cache of item sizes
            _sizeList.Clear();
            _viewList.Clear();
            _viewToGap.Clear();

            int      totalWidth    = 0;
            ViewBase previousChild = null;

            // Find the size of each individual visible child item
            for (int i = 0; i < this.Count; i++)
            {
                ViewBase child = this[i];

                // Only interested in visible items
                if (child.Visible)
                {
                    // Are we positioning a cluster?
                    if (child is ViewLayoutRibbonGroupCluster)
                    {
                        // Inform cluster if it is immediatley after another cluster (and so potentially needs a separator)
                        ViewLayoutRibbonGroupCluster clusterChild = (ViewLayoutRibbonGroupCluster)child;
                        clusterChild.StartSeparator = (previousChild != null) && !(previousChild is ViewLayoutRibbonGroupCluster);
                        clusterChild.EndSeparator   = true;
                    }

                    // Can we calculate the spacing gap between the previous and this item
                    if (previousChild != null)
                    {
                        if (_viewToItem.ContainsKey(child) &&
                            _viewToItem.ContainsKey(previousChild))
                        {
                            // Cast to correct type
                            IRibbonGroupItem childItem    = _viewToItem[child] as IRibbonGroupItem;
                            IRibbonGroupItem previousItem = _viewToItem[previousChild] as IRibbonGroupItem;

                            // Find the requested gap between them
                            _viewToGap.Add(child, childItem.ItemGap(previousItem));
                        }
                        else
                        {
                            // Default the gap
                            _viewToGap.Add(child, DEFAULT_GAP);
                        }
                    }

                    // Get requested size of the child
                    Size childSize = child.GetPreferredSize(context);

                    // Add to list of visible child sizes
                    _sizeList.Add(childSize);
                    _viewList.Add(child);

                    // Cache total visible width for later
                    totalWidth += childSize.Width;

                    // This is now the previous child
                    previousChild = child;
                }
            }

            // Find the item size specific preferred calculation
            switch (_currentSize)
            {
            case GroupItemSize.Large:
                return(LargeMediumPreferredSize(totalWidth, ref _split1Large));

            case GroupItemSize.Medium:
                return(LargeMediumPreferredSize(totalWidth, ref _split1Medium));

            case GroupItemSize.Small:
                return(SmallPreferredSize(totalWidth));

            default:
                // Should never happen!
                Debug.Assert(false);
                return(Size.Empty);
            }
        }
예제 #3
0
        private void ProcessPacket()
        {
            var header = (PACKET_HEADER)PACKET_HEADER.Deserialize(data, typeof(PACKET_HEADER));

            this.RecvMessage = header.command.ToString();
            switch (header.command)
            {
            case PACKET_COMMAND.PACKET_SC_LOGIN_ACK:
            {
                var packet = (PKS_SC_LOGIN_ACK)PACKET_HEADER.Deserialize(data, typeof(PKS_SC_LOGIN_ACK));
            }
            break;

            case PACKET_COMMAND.PACKET_SC_CHAT:
            {
                var packet = (PKS_SC_CHAT)PACKET_HEADER.Deserialize(data, typeof(PKS_SC_CHAT));
                this.Chat = new string(packet.chat).Split('\0')[0];
                this.ChatCount++;
            }
            break;

            case PACKET_COMMAND.PACKET_SC_MOVE:
            {
                var packet = (PKS_SC_MOVE)PACKET_HEADER.Deserialize(data, typeof(PKS_SC_MOVE));
                this.Position = packet.dest;
            }
            break;

            case PACKET_COMMAND.PACKET_SC_VIEW:
            {
                var packet = (PKS_SC_VIEW)PACKET_HEADER.Deserialize(data, typeof(PKS_SC_VIEW));
                lock (lockObject)
                {
                    if (ViewList == null)
                    {
                        break;
                    }
                    foreach (var view in ViewList)
                    {
                        view.IsUpdate = false;
                    }
                    var name = new string(packet.commanderID1).Split('\0')[0];
                    if (name != "None")
                    {
                        bool isFind = false;
                        foreach (var view in ViewList)
                        {
                            if (view.Name == name)
                            {
                                view.PositionX = packet.dest1.X;
                                view.PositionY = packet.dest1.Y;
                                view.IsUpdate  = true;
                                isFind         = true;
                                break;
                            }
                        }
                        if (!isFind)
                        {
                            var view = new ClientView(packet.dest1.X, packet.dest1.Y, name);
                            ViewList.Add(view);
                        }
                    }


                    name = new string(packet.commanderID2).Split('\0')[0];
                    if (name != "None")
                    {
                        bool isFind = false;
                        foreach (var view in ViewList)
                        {
                            if (view.Name == name)
                            {
                                view.PositionX = packet.dest2.X;
                                view.PositionY = packet.dest2.Y;
                                view.IsUpdate  = true;
                                isFind         = true;
                                break;
                            }
                        }
                        if (!isFind)
                        {
                            ViewList.Add(new ClientView(packet.dest2.X, packet.dest2.Y, name));
                        }
                    }
                    name = new string(packet.commanderID3).Split('\0')[0];
                    if (name != "None")
                    {
                        bool isFind = false;
                        foreach (var view in ViewList)
                        {
                            if (view.Name == name)
                            {
                                view.PositionX = packet.dest3.X;
                                view.PositionY = packet.dest3.Y;
                                view.IsUpdate  = true;
                                isFind         = true;
                                break;
                            }
                        }
                        if (!isFind)
                        {
                            ViewList.Add(new ClientView(packet.dest3.X, packet.dest3.Y, name));
                        }
                    }

                    name = new string(packet.commanderID4).Split('\0')[0];
                    if (name != "None")
                    {
                        bool isFind = false;
                        foreach (var view in ViewList)
                        {
                            if (view.Name == name)
                            {
                                view.PositionX = packet.dest4.X;
                                view.PositionY = packet.dest4.Y;
                                view.IsUpdate  = true;
                                isFind         = true;
                                break;
                            }
                        }
                        if (!isFind)
                        {
                            ViewList.Add(new ClientView(packet.dest4.X, packet.dest4.Y, name));
                        }
                    }

                    name = new string(packet.commanderID5).Split('\0')[0];
                    if (name != "None")
                    {
                        bool isFind = false;
                        foreach (var view in ViewList)
                        {
                            if (view.Name == name)
                            {
                                view.PositionX = packet.dest5.X;
                                view.PositionY = packet.dest5.Y;
                                view.IsUpdate  = true;
                                isFind         = true;
                                break;
                            }
                        }
                        if (!isFind)
                        {
                            ViewList.Add(new ClientView(packet.dest5.X, packet.dest5.Y, name));
                        }
                    }
                    foreach (var view in ViewList.ToList())
                    {
                        if (!view.IsUpdate)
                        {
                            ViewList.Remove(view);
                        }
                    }
                }

                /*
                 *
                 * if (new string(packet.commanderID2).Split('\0')[0] == "")
                 * {
                 *  break;
                 * }
                 * clientViewList.Add(new ClientView(packet.dest2.X, packet.dest2.Y, new string(packet.commanderID2).Split('\0')[0]));
                 *
                 *
                 * if (new string(packet.commanderID3).Split('\0')[0] == "")
                 * {
                 *  break;
                 * }
                 * clientViewList.Add(new ClientView(packet.dest3.X, packet.dest3.Y, new string(packet.commanderID3).Split('\0')[0]));
                 */
            }
            break;

            default:
                this.Error = "wrong packet command";
                break;
            }
        }