Пример #1
0
            public void onMessage(IClientSessionChannel session, Cometd.Bayeux.IMessage message)
            {
                Console.WriteLine(message);
                Google.ProtocolBuffers.IMessage msg = Util.restoreMessage(message);
                if (msg.GetType().ToString().Equals("sally.CellPosition"))
                {
                    CellPosition pos = (CellPosition)msg;
                    int col = pos.Col;
                    int row = pos.Row;
                    int sheet = pos.Sheet;
                    RangeSelection click = RangeSelection.CreateBuilder().SetStartCol(col).SetStartRow(row).SetEndRow(row).SetEndCol(col).SetSheet(sheet + "").Build();
                    moveCursorAt(click);

                }
                if (msg.GetType().ToString().Equals("sally.SaveASM"))
                {
                    SaveASM asm = (SaveASM)msg;
                    saveSemanticMap(asm.SemanticData);

                }
                /*    if (msg.GetType().ToString().Equals("sally.HighlightRanges"))
                    {
                        // Change to an Array or ArrayList. Might be faster.
                        List<HighlightRange> arr = new List<HighlightRange>(((HighlightRanges)msg).RangeList);

                        String activeSheet = Globals.ThisAddIn.Application.ActiveSheet.Name;    // Get the name of the active sheet
                        int i=0;
                        foreach (HighlightRange el in arr)
                        {
                            if(el.Sheet.Equals(activeSheet, StringComparison.InvariantCultureIgnoreCase)){
                                selectMultipleRanges(new List<RangeSelection> (el.RangesList), el.Sheet);
                            //Highlight range
                                break;
                            }
                            i++;
                        }
                        if(i>=arr.Count && arr.Count >0){
                            selectMultipleRanges(new List<RangeSelection>(arr[0].RangesList), arr[0].Sheet);
                        }

                        int col = ((NavigateTo)msg).Col;
                        int row = ((NavigateTo)msg).Row;
                        String sheet = ((NavigateTo)msg).Sheet;
                        RangeSelection click = RangeSelection.CreateBuilder().SetStartCol(col).SetStartRow(row).SetEndRow(row).SetEndCol(col).SetSheet(sheet).Build();
                        moveCursorAt(click);

                    }*/
            }
Пример #2
0
 public void onMessage(IClientSessionChannel session, Cometd.Bayeux.IMessage message)
 {
     if (message.Successful)
     {
         Console.WriteLine("had something on " + message.Channel);
         Console.WriteLine("namely " + message.JSON);
     }
 }
Пример #3
0
            public void onMessage(IClientSessionChannel session, Cometd.Bayeux.IMessage message)
            {
                Console.WriteLine(message);
                Google.ProtocolBuffers.IMessage msg = Util.restoreMessage(message);
                if (msg.GetType().ToString().Equals("sally.AlexRangeRequest"))
                {
                    sally.AlexRangeRequest pos = (sally.AlexRangeRequest)msg;
                    String dump = pos.ToJson();

                    string filename = new System.Uri(pos.FileName).AbsolutePath;
                    foreach (RangeSelection i in pos.SelectionList)
                    {
                        moveSelectionTo(i, filename);
                    }

                    //int col = pos.SelectionList;
                    //int row = pos.Row;
                    //int sheet = pos.Sheet;
                    //RangeSelection click = RangeSelection.CreateBuilder().SetStartCol(col).SetStartRow(row).SetEndRow(row).SetEndCol(col).SetSheet(sheet + "").Build();
                    //Microsoft.Office.Interop.Excel.Range range = Globals.ThisAddIn.Application.ActiveSheet.Cells[click.StartRow + 1, click.StartCol + 1].Select();

                }
                if (msg.GetType().ToString().Equals("sally.SaveASM"))
                {
                    SaveASM asm = (SaveASM)msg;
                    saveSemanticMap(asm.SemanticData);

                }
                /*    if (msg.GetType().ToString().Equals("sally.HighlightRanges"))
                    {
                        // Change to an Array or ArrayList. Might be faster.
                        List<HighlightRange> arr = new List<HighlightRange>(((HighlightRanges)msg).RangeList);

                        String activeSheet = Globals.ThisAddIn.Application.ActiveSheet.Name;    // Get the name of the active sheet
                        int i=0;
                        foreach (HighlightRange el in arr)
                        {
                            if(el.Sheet.Equals(activeSheet, StringComparison.InvariantCultureIgnoreCase)){
                                selectMultipleRanges(new List<RangeSelection> (el.RangesList), el.Sheet);
                            //Highlight range
                                break;
                            }
                            i++;
                        }
                        if(i>=arr.Count && arr.Count >0){
                            selectMultipleRanges(new List<RangeSelection>(arr[0].RangesList), arr[0].Sheet);
                        }

                        int col = ((NavigateTo)msg).Col;
                        int row = ((NavigateTo)msg).Row;
                        String sheet = ((NavigateTo)msg).Sheet;
                        RangeSelection click = RangeSelection.CreateBuilder().SetStartCol(col).SetStartRow(row).SetEndRow(row).SetEndCol(col).SetSheet(sheet).Build();
                        moveCursorAt(click);

                    }*/
            }
Пример #4
0
            public void onMessage(IClientSession session, String channel, Cometd.Bayeux.IMessage message)
            {
                if (message.Successful)
                {
                    Console.WriteLine("had something on " + message.Channel);
                    Console.WriteLine("namely " + message.JSON);
                }

                if (channel.Equals("/do/select")) //|| (message is AlexRangeRequest)
                {

                }

                if (channel.Equals("/get/data"))
                {
                    //call Alex_API from here
                }
            }
Пример #5
0
        /// <summary>
        /// Restore a cometd message to a GoogleMessage
        /// </summary>
        /// <param name="message">The Cometd message.</param>
        /// <returns>Google.ProtocolBuffers message.</returns>
        public static Google.ProtocolBuffers.IMessage restoreMessage(Cometd.Bayeux.IMessage message)
        {
            Console.WriteLine(message);
            Dictionary<string, object> input = (Dictionary<string, object>)message;
            string type = tryGetString(input, "type");
            string s = tryGetString(input, "s");
            if (type == "" || s == "")
            {
                object myData = null;
                try
                {
                    myData = input["data"];
                }
                catch (Exception ex)
                { }
                Dictionary<string, object> newInput = (Dictionary<string, object>)myData;
                type = tryGetString(newInput, "type");
                s = tryGetString(newInput, "s");
                if (type == "" || s == "")
                    return null;
            }

            return Util.stringToProto(type, s);
        }
Пример #6
0
 public void onMessage(IClientSessionChannel session, Cometd.Bayeux.IMessage message)
 {
     Console.WriteLine(message);
     Google.ProtocolBuffers.IMessage msg = Util.restoreMessage(message);
 }