Пример #1
0
        public string GetSpyHtml()
        {
            UserActionList userActionList = new UserActionList(UserActionCache.GetLatestUserActions(HostProfile.HostID));

            userActionList.ShowModeratorActions = KickUserProfile.IsModerator;
            return(ControlHelper.RenderControl(userActionList));
        }
Пример #2
0
        static public Edge Find(UserActionList theString, Dictionary <int, Edge> edges, int node, UserAction c)
        {
            int i = Hash(node, c);

            for (; ;)
            {
                if (!edges.ContainsKey(i))
                {
                    edges.Add(i, new Edge(theString));
                }
                if (edges[i].startNode == node)
                {
                    //if (c == theString[edges[i].indexOfFirstCharacter])
                    //{
                    //    return edges[i];
                    //}
                    if (c.Equals(theString[edges[i].indexOfFirstCharacter]))
                    {
                        return(edges[i]);
                    }
                }
                if (edges[i].startNode == -1)
                {
                    return(edges[i]);
                }
                i = ++i % HASH_TABLE_SIZE;
            }
            //return null;
        }
Пример #3
0
        public MainForm()
        {
            // Define the controller for the application
            m_Controller = new ViewController(this);

            InitializeComponent();

            // All user interface actions should be handled via the UserActionList technique.
            // Those that deal with map navigation get routed to the map control, the rest
            // will get routed to methods in this class.

            m_Actions = new UserActionList();

            // File menu...
            AddAction(fileOpenMenuItem, IsFileOpenEnabled, FileOpen);
            AddAction(fileExitMenuItem, IsFileExitEnabled, FileExit);

            // View menu...
            AddAction(mnuViewAutoSelect, null, AutoSelect);
            AddAction(DisplayToolId.Overview, new ToolStripItem[] { mnuViewOverview, ctxViewOverview });
            AddAction(DisplayToolId.ZoomIn, new ToolStripItem[] { mnuViewZoomIn, ctxViewZoomIn });
            AddAction(DisplayToolId.ZoomOut, new ToolStripItem[] { mnuViewZoomOut, ctxViewZoomOut });
            AddAction(DisplayToolId.ZoomRectangle, new ToolStripItem[] { mnuViewZoomRectangle, ctxViewZoomRectangle });
            AddAction(DisplayToolId.DrawScale, new ToolStripItem[] { mnuViewDrawScale, ctxViewDrawScale });
            AddAction(DisplayToolId.Magnify, new ToolStripItem[] { mnuViewMagnify, ctxViewMagnify });
            AddAction(DisplayToolId.NewCentre, new ToolStripItem[] { mnuViewNewCenter, ctxViewNewCenter });
            AddAction(DisplayToolId.Pan, new ToolStripItem[] { mnuViewPan, ctxViewPan });
            AddAction(DisplayToolId.Previous, new ToolStripItem[] { mnuViewPrevious, ctxViewPrevious });
            AddAction(DisplayToolId.Next, new ToolStripItem[] { mnuViewNext, ctxViewNext });
            AddAction(mnuViewStatusBar, IsViewStatusBarEnabled, ViewStatusBar);

            // Update UI in idle time
            Application.Idle += OnIdle;
        }
Пример #4
0
        static public int SplitEdge(Suffix s, UserActionList theString, Dictionary <int, Edge> edges, Dictionary <int, Node> nodes, Edge edge)
        {
            Remove(theString, edges, edge);
            Edge newEdge = new Edge(theString, edge.indexOfFirstCharacter,
                                    edge.indexOfFirstCharacter + s.indexOfLastCharacter
                                    - s.indexOfFirstCharacter, s.originNode);

            Edge.Insert(theString, edges, newEdge);
            //nodes[newEdge.endNode].suffixNode = s.originNode;
            //newEdge.Insert();
            if (nodes.ContainsKey(newEdge.endNode))
            {
                nodes[newEdge.endNode].suffixNode = s.originNode;
            }
            else
            {
                Node newNode = new Node();
                newNode.suffixNode = s.originNode;
                nodes.Add(newEdge.endNode, newNode);
            }

            edge.indexOfFirstCharacter += s.indexOfLastCharacter - s.indexOfFirstCharacter + 1;
            edge.startNode              = newEdge.endNode;
            Edge.Insert(theString, edges, edge);
            //Insert();
            return(newEdge.endNode);
        }
Пример #5
0
 public Suffix(Suffix suffix)
 {
     this.originNode            = suffix.originNode;
     this.indexOfFirstCharacter = suffix.indexOfFirstCharacter;
     this.indexOfLastCharacter  = suffix.indexOfLastCharacter;
     this.theString             = suffix.theString;
     this.edges = suffix.edges;
 }
Пример #6
0
 public Suffix(UserActionList theString, Dictionary <int, Edge> edges, int node, int start, int stop)
 {
     this.originNode            = node;
     this.indexOfFirstCharacter = start;
     this.indexOfLastCharacter  = stop;
     this.theString             = theString;
     this.edges = edges;
 }
Пример #7
0
 public Edge(Edge edge)
 {
     this.startNode             = edge.startNode;
     this.endNode               = edge.endNode;
     this.indexOfFirstCharacter = edge.indexOfFirstCharacter;
     this.indexOfLastCharacter  = edge.indexOfLastCharacter;
     this.theString             = edge.theString;
 }
Пример #8
0
 public Edge(UserActionList theString, int indexOfFirstCharacter, int indexOfLastCharacter, int parentNode)
 {
     this.theString             = theString;
     this.indexOfFirstCharacter = indexOfFirstCharacter;
     this.indexOfLastCharacter  = indexOfLastCharacter;
     this.startNode             = parentNode;
     this.endNode = Node.Count++;
 }
Пример #9
0
 public SuffixTree(List <UserAction> theString)
 {
     this.theString = new UserActionList(theString, true);
     this.theString.Add(new TerminalAction());
     Nodes = new Dictionary <int, Node>();
     Edges = new Dictionary <int, Edge>();
     edges = new Edge(this.theString);
 }
Пример #10
0
        static public void Insert(UserActionList theString, Dictionary <int, Edge> edges, Edge edge)
        {
            int i = Hash(edge.startNode, theString[edge.indexOfFirstCharacter]);

            if (!edges.ContainsKey(i))
            {
                edges.Add(i, new Edge(theString));
            }
            while (edges[i].startNode != -1)
            {
                i = ++i % HASH_TABLE_SIZE;
                if (!edges.ContainsKey(i))
                {
                    edges.Add(i, new Edge(theString));
                }
            }
            edges[i] = new Edge(edge);
        }
Пример #11
0
        static public void Remove(UserActionList theString, Dictionary <int, Edge> edges, Edge edge)
        {
            edge = new Edge(edge);
            int i = Hash(edge.startNode, theString[edge.indexOfFirstCharacter]);

            while (edges[i].startNode != edge.startNode || edges[i].indexOfFirstCharacter != edge.indexOfFirstCharacter)
            {
                i = ++i % HASH_TABLE_SIZE;
            }

            for (; ;)
            {
                edges[i].startNode = -1;
                int j = i;
                for (; ;)
                {
                    i = ++i % HASH_TABLE_SIZE;
                    if (!edges.ContainsKey(i))
                    {
                        edges.Add(i, new Edge(theString));
                    }
                    if (edges[i].startNode == -1)
                    {
                        return;
                    }

                    int r = Hash(edges[i].startNode, theString[edges[i].indexOfFirstCharacter]);
                    if (i >= r && r > j)
                    {
                        continue;
                    }
                    if (r > j && j > i)
                    {
                        continue;
                    }
                    if (j > i && i >= r)
                    {
                        continue;
                    }
                    break;
                }
                edges[j] = new Edge(edges[i]);
            }
        }
Пример #12
0
        private bool WalkTree(int start_node, UserActionList deepest_prefix, int depth)
        {
            List <UserAction> processed_actions = new List <UserAction>();
            int  d            = depth + 1;
            bool is_leaf_node = true;

            for (int i = 0; i < _tree.theString.Count; i++)
            {
                UserAction action = _tree.theString[i];
                if (!processed_actions.Contains(action))
                {
                    Edge edge = Edge.Find(_tree.theString, _tree.Edges, start_node, action);
                    if (edge.startNode != -1)
                    {
                        is_leaf_node = false;
                        processed_actions.Add(action);
                        UserActionList acl = new UserActionList(_tree.theString.GetRange(edge.indexOfFirstCharacter, (edge.indexOfLastCharacter - edge.indexOfFirstCharacter) + 1));
                        if (acl[acl.Count - 1].Id == -1)
                        {
                            acl.RemoveAt(acl.Count - 1);
                        }
                        bool deepest_non_leaf_leading_edge = WalkTree(edge.endNode, acl, d);
                        if (deepest_non_leaf_leading_edge && depth > 1)
                        {
                            if (!_deepested_repeated_prefixes.ContainsKey(deepest_prefix))
                            {
                                _deepested_repeated_prefixes.Add(deepest_prefix, depth);
                            }
                            else
                            if (depth > _deepested_repeated_prefixes[deepest_prefix])
                            {
                                _deepested_repeated_prefixes[deepest_prefix] = depth;
                            }
                        }
                    }
                }
            }
            return(is_leaf_node);
        }
Пример #13
0
        public void GenerateSuggestions(UserActionList[] repetitions, Dictionary <short, List <Generalization> > generalizations)
        {
            List <Suggestion> suggestions = new List <Suggestion>();
            UserActionList    basic_actions;
            Dictionary <UserAction, List <Generalization> > basic_generalizations;

            foreach (UserActionList repetition in repetitions)
            {
                basic_actions         = new UserActionList(repetition);
                basic_generalizations = new Dictionary <UserAction, List <Generalization> >();
                foreach (UserAction action in repetition)
                {
                    foreach (KeyValuePair <short, List <Generalization> > pair in generalizations)
                    {
                        List <Generalization> new_gens = new List <Generalization>();
                        if (pair.Key == action.Id)
                        {
                            foreach (Generalization gen in pair.Value)
                            {
                                new_gens.Add((Generalization)gen.Clone());
                            }
                            //if (new_gens.Count == 0)
                            //    System.Windows.Forms.MessageBox.Show("huston, we got a problem :(");
                            basic_generalizations.Add(action, new_gens);
                        }
                    }
                }
                suggestions.Add(new Suggestion(basic_actions, basic_generalizations));
            }
            suggestions.RemoveAll(delegate(Suggestion suggestion)
            {
                return(!suggestion.Valid);
            });
            suggestions.Sort(delegate(Suggestion a, Suggestion b)
            {
                if (a.BasicActionList.Count == b.BasicActionList.Count)
                {
                    return(a.Time.CompareTo(b.Time));
                }
                else
                {
                    return(a.BasicActionList.Count.CompareTo(b.BasicActionList.Count));
                }
            });
            suggestions.Reverse();
            _suggestions = suggestions.ToArray();
            if (_suggestions.Length > 0)
            {
                if (!_has_suggestions)
                {
                    _has_suggestions = true;
                    NewSuggestion();
                }
            }
            else
            {
                if (_has_suggestions)
                {
                    _has_suggestions = false;
                    NoNewSuggestion();
                }
            }
        }
Пример #14
0
 public Edge(UserActionList theString)
 {
     this.theString = theString;
     this.startNode = -1;
 }