예제 #1
0
        public static ElementWindow CreateWindowFromDescriptor(WindowDescriptor windowDescriptor)
        {
            ElementDescriptorMain mainDescriptor = windowDescriptor.MainElementDescriptor;
            ElementWindow         elementWindow  = new ElementWindow();
            List <IElement>       elements       = new List <IElement>();

            elementWindow.ElementDescriptor = mainDescriptor;
            foreach (ElementDescriptor elementDescriptor in windowDescriptor.ElementDescriptors)
            {
                if (elementDescriptor != mainDescriptor)
                {
                    try {
                        IElement element = CreateElementFromDescriptor(elementDescriptor);

                        elements.Add(element);
                        elementWindow.Children.Add((UIElement)element);
                    } catch (Exception e) {
                        Console.WriteLine("Error while creating an interface element: " + e.Message);
                    }
                }
            }

            elementWindow.ChildElements       = elements.ToArray();
            elementWindow.Margin              = new Thickness(0, 0, 0, 0);
            elementWindow.HorizontalAlignment = HorizontalAlignment.Stretch;
            elementWindow.VerticalAlignment   = VerticalAlignment.Stretch;
            elementWindow.SizeChanged        += (object sender, SizeChangedEventArgs e) => UpdateAnchors(elementWindow, elements);

            return(elementWindow);
        }
예제 #2
0
        public XWindow createItemWindow(XWindow xWindow)
        {
            // xMSF is set by initialize(Object[])
            try
            {
                // get XWindowPeer
                XWindowPeer xWinPeer = (XWindowPeer)xWindow;
                Object      o        = _xMsf.createInstanceWithContext("com.sun.star.awt.Toolkit", OO.GetContext());
                XToolkit    xToolkit = (XToolkit)o;
                // create WindowDescriptor
                WindowDescriptor wd = new WindowDescriptor();
                wd.Type              = WindowClass.SIMPLE;
                wd.Parent            = xWinPeer;
                wd.Bounds            = new Rectangle(0, 0, 20, 23);
                wd.ParentIndex       = (short)-1;
                wd.WindowAttributes  = WindowAttribute.SHOW;
                wd.WindowServiceName = "pushbutton";
                // create Button
                XWindowPeer cBox_xWinPeer = xToolkit.createWindow(wd);// null here
                var         xButton       = (XButton)cBox_xWinPeer;
                xButton.setLabel("My Texte");
                XWindow cBox_xWindow = (XWindow)cBox_xWinPeer;
                cBox_xWindow.addKeyListener(this);

                return(cBox_xWindow);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("createItemWindow left not o.k.\n" + e);
                return(null);
            }
        }
예제 #3
0
        private double weightcharge = 0.5; // defined as a constant within the UDO; this could be passed as a config if required

        public override IEnumerable <IntervalEvent <VehicleWeightInfo> > GenerateOutput(
            IEnumerable <IntervalEvent <TollReading> > events,
            WindowDescriptor windowDescriptor)
        {
            List <IntervalEvent <VehicleWeightInfo> > output = new List <IntervalEvent <VehicleWeightInfo> >();

            // Identify any commercial vehicles in this window for the given window duration
            foreach (var e in events.Where(e => e.StartTime.Hour >= 0 && e.Payload.VehicleType == 2))
            {
                // create an output interval event
                IntervalEvent <VehicleWeightInfo> vehicleWeightEvent = CreateIntervalEvent();

                // populate the output interval event
                vehicleWeightEvent.StartTime = e.StartTime;
                vehicleWeightEvent.EndTime   = e.EndTime;
                vehicleWeightEvent.Payload   = new VehicleWeightInfo
                {
                    LicensePlate = e.Payload.LicensePlate,
                    Weight       = e.Payload.VehicleWeight,

                    // here is the interesting part; note how the output is dependent on
                    // the start and end timestamps of the input event. The weight charge
                    // is a function of the rush hour definition, the weigh charge factor
                    // and the vehicle tonnage itself
                    WeightCharge = ((e.StartTime.Hour >= 7 && e.StartTime.Hour <= 14) ? 2 : 1) * this.weightcharge * e.Payload.VehicleWeight
                };

                // output the event via the IEnumerable interface
                output.Add(vehicleWeightEvent);
            }

            return(output);
        }
예제 #4
0
        public InterfaceDescriptor Interface()
        {
            List <WindowDescriptor>             windowDescriptors   = new();
            List <MacroSetDescriptor>           macroSetDescriptors = new();
            Dictionary <string, MenuDescriptor> menuDescriptors     = new();

            var  serializationManager = IoCManager.Resolve <ISerializationManager>();
            bool parsing = true;

            while (parsing)
            {
                try {
                    WindowDescriptor windowDescriptor = Window(serializationManager);
                    if (windowDescriptor != null)
                    {
                        windowDescriptors.Add(windowDescriptor);
                        Newline();
                    }

                    MacroSetDescriptor macroSet = MacroSet(serializationManager);
                    if (macroSet != null)
                    {
                        macroSetDescriptors.Add(macroSet);
                        Newline();
                    }

                    MenuDescriptor menu = Menu(serializationManager);
                    if (menu != null)
                    {
                        menuDescriptors.Add(menu.Name, menu);
                        Newline();
                    }

                    if (windowDescriptor == null && macroSet == null && menu == null)
                    {
                        parsing = false;
                    }
                } catch (CompileErrorException) { //Error recovery
                    Token token = Current();
                    while (token.Type is not(TokenType.DMF_Window or TokenType.DMF_Macro or TokenType.DMF_Menu))
                    {
                        token = Advance();

                        if (token.Type == TokenType.EndOfFile)
                        {
                            parsing = false;
                            break;
                        }
                    }
                }
            }

            Consume(TokenType.EndOfFile, "Expected EOF");
            return(new InterfaceDescriptor(windowDescriptors, macroSetDescriptors, menuDescriptors));
        }
        public XWindowPeer createNonModalWindowPeer()
        {
            try
            {
                XToolkit xToolkit = (XToolkit)MXMcf
                        .createInstanceWithContext("com.sun.star.awt.Toolkit",
                             MXContext);

            WindowDescriptor aDescriptor = new WindowDescriptor();
            aDescriptor.Type = WindowClass.TOP;
            aDescriptor.WindowServiceName = "window";
            aDescriptor.ParentIndex = -1;
            //aDescriptor.Parent = xToolkit.getDesktopWindow();
            aDescriptor.Parent = null;
            aDescriptor.Bounds = new Rectangle(100, 200, 300, 400);

            aDescriptor.WindowAttributes = WindowAttribute.BORDER
                  | WindowAttribute.MOVEABLE 
                  | WindowAttribute.SIZEABLE
                  | WindowAttribute.CLOSEABLE;

            XWindowPeer xPeer = xToolkit.createWindow(aDescriptor);

            XWindow xWindow = (XWindow)xPeer;
            xWindow.setVisible(false);
            MXDialogControl.createPeer(xToolkit, xPeer);

            MXWindowPeer = MXDialogControl.getPeer();

            return MXWindowPeer;

            }
            catch (unoidl.com.sun.star.uno.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("uno.Exception:");
                System.Diagnostics.Debug.WriteLine(ex);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("System.Exception:");
                System.Diagnostics.Debug.WriteLine(ex);
            }
            return null;
        }
예제 #6
0
        public InterfaceDescriptor Interface()
        {
            List <WindowDescriptor>             windowDescriptors   = new();
            List <MacroSetDescriptor>           macroSetDescriptors = new();
            Dictionary <string, MenuDescriptor> menuDescriptors     = new();

            var  serializationManager = IoCManager.Resolve <ISerializationManager>();
            bool parsing = true;

            while (parsing)
            {
                WindowDescriptor windowDescriptor = Window(serializationManager);
                if (windowDescriptor != null)
                {
                    windowDescriptors.Add(windowDescriptor);
                    Newline();
                }

                MacroSetDescriptor macroSet = MacroSet(serializationManager);
                if (macroSet != null)
                {
                    macroSetDescriptors.Add(macroSet);
                    Newline();
                }

                MenuDescriptor menu = Menu(serializationManager);
                if (menu != null)
                {
                    menuDescriptors.Add(menu.Name, menu);
                    Newline();
                }

                if (windowDescriptor == null && macroSet == null && menu == null)
                {
                    parsing = false;
                }
            }

            Consume(TokenType.EndOfFile, "Expected EOF");
            return(new InterfaceDescriptor(windowDescriptors, macroSetDescriptors, menuDescriptors));
        }
예제 #7
0
        public InterfaceDescriptor Interface()
        {
            List <WindowDescriptor> windowDescriptors = new();

            bool parsing = true;

            while (parsing)
            {
                WindowDescriptor windowDescriptor = Window();
                if (windowDescriptor != null)
                {
                    Newline();
                    windowDescriptors.Add(windowDescriptor);
                }

                bool macro = Macro();
                if (macro)
                {
                    Newline();
                }

                bool menu = Menu();
                if (menu)
                {
                    Newline();
                }

                if (windowDescriptor == null && !macro && !menu)
                {
                    parsing = false;
                }
            }

            Consume(TokenType.EndOfFile, "Expected EOF");
            return(new InterfaceDescriptor(windowDescriptors));
        }
예제 #8
0
        /// <summary>
        /// Computes the aggregation over a window.
        /// </summary>
        /// <param name="events">Set of events contained in the window.</param>
        /// <param name="windowDescriptor">Window definition.</param>
        /// <returns>Aggregation result.</returns>
        public override float GenerateOutput(IEnumerable <IntervalEvent <float> > events, WindowDescriptor windowDescriptor)
        {
            // Make sure that the events are ordered in time.
            var orderedEvent = events.OrderBy(e => e.StartTime);

            return(orderedEvent.Last().Payload - orderedEvent.First().Payload);
        }
        public static XControlContainer createDialog(XMultiComponentFactory xMultiComponentFactory, XComponentContext xContext,
            int posX, int posY, int width, int height, string title
            )
        {

            //dialog model
            Object oDialogModel = xMultiComponentFactory.createInstanceWithContext(
                  "com.sun.star.awt.UnoControlDialogModel", xContext);


            XPropertySet xPSetDialog = (XPropertySet)oDialogModel;
            xPSetDialog.setPropertyValue("PositionX", Any.Get(posX));
            xPSetDialog.setPropertyValue("PositionY", Any.Get(posY));
            xPSetDialog.setPropertyValue("Width", Any.Get(width));
            xPSetDialog.setPropertyValue("Height", Any.Get(height));
            xPSetDialog.setPropertyValue("Title", Any.Get(title));

            // get service manager from  dialog model
            XMultiServiceFactory MXMsfDialogModel = (XMultiServiceFactory)oDialogModel;

            // dialog control model
            Object oUnoDialog = xMultiComponentFactory.createInstanceWithContext(
                  "com.sun.star.awt.UnoControlDialog", xContext);


            XControl MXDialogControl = (XControl)oUnoDialog;
            XControlModel xControlModel = (XControlModel)oDialogModel;
            MXDialogControl.setModel(xControlModel);



            XToolkit xToolkit = (XToolkit)xMultiComponentFactory
                        .createInstanceWithContext("com.sun.star.awt.Toolkit",
                             xContext);

            WindowDescriptor aDescriptor = new WindowDescriptor();
            aDescriptor.Type = WindowClass.TOP;
            aDescriptor.WindowServiceName = "";
            aDescriptor.ParentIndex = -1;
            aDescriptor.Parent = xToolkit.getDesktopWindow();
            aDescriptor.Bounds = new Rectangle(100, 200, 300, 400);

            aDescriptor.WindowAttributes = WindowAttribute.BORDER
                  | WindowAttribute.MOVEABLE | WindowAttribute.SIZEABLE
                  | WindowAttribute.CLOSEABLE;

            XWindowPeer xPeer = xToolkit.createWindow(aDescriptor);

            XWindow xWindow = (XWindow)xPeer;
            xWindow.setVisible(false);
            MXDialogControl.createPeer(xToolkit, xPeer);

            // execute the dialog
            XDialog xDialog = (XDialog)oUnoDialog;
            xDialog.execute();

            // dispose the dialog
            XComponent xComponent = (XComponent)oUnoDialog;
            xComponent.dispose();

            return oUnoDialog as XControlContainer;
        }
예제 #10
0
        public override string GenerateOutput(IEnumerable <Microsoft.ComplexEventProcessing.IntervalEvent <TwitterDataTerm> > eventData, WindowDescriptor windowDescriptor)
        {
            return("watis");

            /*
             * var g = eventData.GroupBy(e => e.Payload.Term);
             * foreach (var group in g)
             * {
             *  var documents = tweets.ToArray();
             *  double[][] inputs = TFIDF.Transform(documents);
             *
             *  return TFIDF.Normalize(inputs).ToString();
             * }*/
        }
        public static XControlContainer createDialog(XMultiComponentFactory xMultiComponentFactory, XComponentContext xContext,
                                                     int posX, int posY, int width, int height, string title
                                                     )
        {
            //dialog model
            Object oDialogModel = xMultiComponentFactory.createInstanceWithContext(
                "com.sun.star.awt.UnoControlDialogModel", xContext);


            XPropertySet xPSetDialog = (XPropertySet)oDialogModel;

            xPSetDialog.setPropertyValue("PositionX", Any.Get(posX));
            xPSetDialog.setPropertyValue("PositionY", Any.Get(posY));
            xPSetDialog.setPropertyValue("Width", Any.Get(width));
            xPSetDialog.setPropertyValue("Height", Any.Get(height));
            xPSetDialog.setPropertyValue("Title", Any.Get(title));

            // get service manager from  dialog model
            XMultiServiceFactory MXMsfDialogModel = (XMultiServiceFactory)oDialogModel;

            // dialog control model
            Object oUnoDialog = xMultiComponentFactory.createInstanceWithContext(
                "com.sun.star.awt.UnoControlDialog", xContext);


            XControl      MXDialogControl = (XControl)oUnoDialog;
            XControlModel xControlModel   = (XControlModel)oDialogModel;

            MXDialogControl.setModel(xControlModel);



            XToolkit xToolkit = (XToolkit)xMultiComponentFactory
                                .createInstanceWithContext("com.sun.star.awt.Toolkit",
                                                           xContext);

            WindowDescriptor aDescriptor = new WindowDescriptor();

            aDescriptor.Type = WindowClass.TOP;
            aDescriptor.WindowServiceName = "";
            aDescriptor.ParentIndex       = -1;
            aDescriptor.Parent            = xToolkit.getDesktopWindow();
            aDescriptor.Bounds            = new Rectangle(100, 200, 300, 400);

            aDescriptor.WindowAttributes = WindowAttribute.BORDER
                                           | WindowAttribute.MOVEABLE | WindowAttribute.SIZEABLE
                                           | WindowAttribute.CLOSEABLE;

            XWindowPeer xPeer = xToolkit.createWindow(aDescriptor);

            XWindow xWindow = (XWindow)xPeer;

            xWindow.setVisible(false);
            MXDialogControl.createPeer(xToolkit, xPeer);

            // execute the dialog
            XDialog xDialog = (XDialog)oUnoDialog;

            xDialog.execute();

            // dispose the dialog
            XComponent xComponent = (XComponent)oUnoDialog;

            xComponent.dispose();

            return(oUnoDialog as XControlContainer);
        }
예제 #12
0
        public override IEnumerable <IntervalEvent <TRegister> > GenerateOutput(IEnumerable <IntervalEvent <TInput> > events, WindowDescriptor windowDescriptor)
        {
            SortedDictionary <DateTimeOffset, EventSet <TInput> > allEvents = new SortedDictionary <DateTimeOffset, EventSet <TInput> >();

            foreach (IntervalEvent <TInput> evt in events)
            {
                if (evt.StartTime.AddTicks(1) != evt.EndTime)
                {
                    // This condition implies an event that is not a point event. This AFA
                    // operator supports only point events, hence we raise an exception.
                    throw new InvalidOperationException("Received an event that is not a point event. The AFA operator only supports point events.");
                }

                EventSet <TInput> eventSet;
                if (!allEvents.TryGetValue(evt.StartTime, out eventSet))
                {
                    eventSet = new EventSet <TInput>(evt.StartTime);
                    allEvents.Add(evt.StartTime, eventSet);
                }

                eventSet.Add(evt);
            }

            List <IntervalEvent <TRegister> > result = new List <IntervalEvent <TRegister> >();
            LinkedList <Run> previousRuns            = null;

            foreach (var item in allEvents)
            {
                previousRuns = this.Insert(result, windowDescriptor.EndTime, previousRuns, item.Value);
            }

            return(result);
        }
예제 #13
0
        public void ReadFromStream(PacketStream stream)
        {
            List <WindowDescriptor> windowDescriptors = new List <WindowDescriptor>();

            int windowCount = stream.ReadByte();

            for (int i = 0; i < windowCount; i++)
            {
                string windowName = stream.ReadString();
                List <ElementDescriptor> elementDescriptors = new List <ElementDescriptor>();

                int elementCount = stream.ReadByte();
                for (int j = 0; j < elementCount; j++)
                {
                    string            elementName = stream.ReadString();
                    DescriptorType    elementType = (DescriptorType)stream.ReadByte();
                    ElementDescriptor elementDescriptor;

                    switch (elementType)
                    {
                    case DescriptorType.Main: elementDescriptor = new ElementDescriptorMain(elementName); break;

                    case DescriptorType.Input: elementDescriptor = new ElementDescriptorInput(elementName); break;

                    case DescriptorType.Button: elementDescriptor = new ElementDescriptorButton(elementName); break;

                    case DescriptorType.Child: elementDescriptor = new ElementDescriptorChild(elementName); break;

                    case DescriptorType.Output: elementDescriptor = new ElementDescriptorOutput(elementName); break;

                    case DescriptorType.Info: elementDescriptor = new ElementDescriptorInfo(elementName); break;

                    case DescriptorType.Map: elementDescriptor = new ElementDescriptorMap(elementName); break;

                    case DescriptorType.Browser: elementDescriptor = new ElementDescriptorBrowser(elementName); break;

                    default: throw new Exception("Invalid descriptor type '" + elementType + "'");
                    }

                    elementDescriptors.Add(elementDescriptor);

                    AttributeType valueType;
                    do
                    {
                        valueType = (AttributeType)stream.ReadByte();
                        switch (valueType)
                        {
                        case AttributeType.Pos: elementDescriptor.Pos = new Point(stream.ReadUInt16(), stream.ReadUInt16()); break;

                        case AttributeType.Size: elementDescriptor.Size = new Size(stream.ReadUInt16(), stream.ReadUInt16()); break;

                        case AttributeType.Anchor1: elementDescriptor.Anchor1 = new Point(stream.ReadUInt16(), stream.ReadUInt16()); break;

                        case AttributeType.Anchor2: elementDescriptor.Anchor2 = new Point(stream.ReadUInt16(), stream.ReadUInt16()); break;

                        case AttributeType.BackgroundColor: elementDescriptor.BackgroundColor = Color.FromArgb(stream.ReadByte(), stream.ReadByte(), stream.ReadByte()); break;

                        case AttributeType.IsVisible: elementDescriptor.IsVisible = stream.ReadBool(); break;

                        case AttributeType.IsDefault: elementDescriptor.IsDefault = stream.ReadBool(); break;

                        case AttributeType.IsPane: ((ElementDescriptorMain)elementDescriptor).IsPane = stream.ReadBool(); break;

                        case AttributeType.Left: ((ElementDescriptorChild)elementDescriptor).Left = stream.ReadString(); break;

                        case AttributeType.Right: ((ElementDescriptorChild)elementDescriptor).Right = stream.ReadString(); break;

                        case AttributeType.IsVert: ((ElementDescriptorChild)elementDescriptor).IsVert = stream.ReadBool(); break;

                        case AttributeType.Text:
                            if (elementDescriptor is ElementDescriptorButton)
                            {
                                ((ElementDescriptorButton)elementDescriptor).Text = stream.ReadString();
                            }
                            break;


                        case AttributeType.End: break;

                        default: throw new Exception("Invalid attribute type '" + valueType + "'");
                        }
                    } while (valueType != AttributeType.End);
                }

                WindowDescriptor windowDescriptor = new WindowDescriptor(windowName, elementDescriptors);
                windowDescriptors.Add(windowDescriptor);
            }

            InterfaceDescriptor = new InterfaceDescriptor(windowDescriptors);
        }
        public XWindow createItemWindow(XWindow xWindow)
        {
            // xMSF is set by initialize(Object[])
            try
            {
                // get XWindowPeer
                XWindowPeer xWinPeer = (XWindowPeer)xWindow;
                Object o = _xMsf.createInstanceWithContext("com.sun.star.awt.Toolkit", OO.GetContext());
                XToolkit xToolkit = (XToolkit)o;
                // create WindowDescriptor
                WindowDescriptor wd = new WindowDescriptor();
                wd.Type = WindowClass.SIMPLE;
                wd.Parent = xWinPeer;
                wd.Bounds = new Rectangle(0, 0, 20, 23);
                wd.ParentIndex = (short)-1;
                wd.WindowAttributes = WindowAttribute.SHOW;
                wd.WindowServiceName = "pushbutton";
                // create Button
                XWindowPeer cBox_xWinPeer = xToolkit.createWindow(wd);// null here
                var xButton = (XButton)cBox_xWinPeer;
                xButton.setLabel("My Texte");
                XWindow cBox_xWindow = (XWindow)cBox_xWinPeer;
                cBox_xWindow.addKeyListener(this);

                return cBox_xWindow;

            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("createItemWindow left not o.k.\n" + e);
                return null;
            }
        }