Example #1
0
        /// <summary>
        /// Draws an event on the grid
        /// </summary>
        /// <param name="ev">The event to draw</param>
        /// <param name="sender">Object  of the corresponding Panel.Paint() Event</param>
        /// <param name="e">PainteventArgs of the corresponding Panel.Paint() Event</param>
        public void DrawSingleEvent(Event ev, object sender, PaintEventArgs e)
        {
            Panel mainPanel = (Panel)sender;
            Event cEvent = ev;
            Graphics cGraphics = e.Graphics;

            // Get position and size
            float[] possize = panelPaintCalc(cEvent);
            float x = possize[0];
            float y = possize[1];
            float duration = possize[2];

            // Do not paint in time region
            if (x < OFFSET_TIME_X)
                throw new ArgumentException("ev.Day Property not valid!", "ev");

            // Ignore Weekend
            if (x > SIZE_X - OFFSET_DAY)
                return;

            // Create Panel
            EventPanel panel = new EventPanel(cEvent);
            panel.Dock = DockStyle.None;
            panel.Location = new Point((int)x, (int)y);
            panel.Name = "panel_" + ev.ID;
            panel.Padding = new Padding(5, 6, 5, 6);
            panel.Size = new Size((int)OFFSET_DAY, (int)duration);
            panel.Click += new EventHandler(panel_Click);
            panel.Paint += new PaintEventHandler(panel_Paint);
            panel.MouseEnter += new EventHandler(panel_MouseEnter);
            panel.MouseLeave += new EventHandler(panel_MouseLeave);
            mainPanel.Controls.Add(panel);      // append Panel
        }
Example #2
0
        public Event getEvent(string id)
        {
            foreach (XmlDocument doc in _libraries)
            {
                XmlElement eventxml = doc.GetElementById(id);

                if (eventxml != null)
                {
                    Event revent = new Event(eventxml.ParentNode.Attributes["id"].Value,                    // parent (id)
                        eventxml.ParentNode.Attributes["name"].Value,                                       // parent (name)
                        eventxml.ParentNode.Attributes["short"].Value);                                     // parent (short)
                    revent.Type = eventxml.Attributes["type"].Value;                                        // type
                    revent.ID = id;                                                                         // id
                    revent.Day = (GermanDay) Enum.Parse(typeof(GermanDay), eventxml["day"].InnerText);      // day
                    revent.Time = eventxml["time"].InnerText;                                               // time
                    revent.Location = eventxml["location"].InnerText;                                       // location
                    revent.Importance = Convert.ToInt32(eventxml["importance"].InnerText);                  // importance
                    revent.Power = Convert.ToInt32(eventxml["power"].InnerText);                            // power

                    return revent;
                }
            }
            return null;
        }
Example #3
0
 public EventPanel(Event ev)
 {
     this.UsedEvent = ev;
     this.BackColor = this.eventTypeColor();
 }
Example #4
0
        private void panel_Click(object sender, EventArgs e)
        {
            if (sender is EventPanel)
            {
                EventPanel panel = (EventPanel)sender;

                if (panel.UsedEvent != _selectedEvent)
                {
                    if (_selectedEvent != null)
                    {
                        foreach (EventPanel ep in panel.Parent.Controls)
                        {
                            if (ep.UsedEvent == _selectedEvent)
                                ep.BackColor = ep.eventTypeColor();
                        }
                    }

                    _selectedEvent = panel.UsedEvent;
                    panel.BackColor = COLOR_SELECTED;
                }
                else
                {
                    _selectedEvent = null;
                    panel.BackColor = panel.eventTypeColor();
                }

                OnSelectedEventChanged(EventArgs.Empty);
            }
        }
Example #5
0
        private float[] panelPaintCalc(Event ev)
        {
            Event cEvent = ev;

            int x = OFFSET_TIME_X + (int)cEvent.Day * OFFSET_DAY;

            // Calculate Coordinates and Size
            string strStarttime = ev.Time.Split(',')[0];
            string[] stime = strStarttime.Split('.');

            float starttime = Convert.ToInt32(stime[0]) + Convert.ToInt32(stime[1]) / 60F;
            float y = (starttime - 8) * SIZE_HOUR_NORMAL + SIZE_HOUR_SMALL + OFFSET_TIME_Y;

            string strEndtime = ev.Time.Split(',')[1];
            string[] etime = strEndtime.Split('.');

            float endtime = Convert.ToInt32(etime[0]) + Convert.ToInt32(etime[1]) / 60F;
            float duration = (endtime - starttime) * SIZE_HOUR_NORMAL;

            float[] result = { x, y, duration };

            return result;
        }
Example #6
0
        public void writeEvent(Event mevent)
        {
            foreach (XmlDocument doc in _libraries)
            {
                XmlElement module = doc.GetElementById(mevent.ParentID);

                if (module != null)
                {
                    XmlNode nodeevent = doc.CreateElement("event");

                    // <event id="_id_" [..]>
                    XmlAttribute eventid = doc.CreateAttribute("id");
                    eventid.Value = mevent.ID;
                    nodeevent.Attributes.Append(eventid);

                    // <event type="_type_" [...]>
                    XmlAttribute eventtype = doc.CreateAttribute("type");
                    eventtype.Value = mevent.Type;
                    nodeevent.Attributes.Append(eventtype);

                    {
                        // <day>_day_</day>
                        XmlNode subnodeday = doc.CreateElement("day");
                        subnodeday.InnerText = mevent.Day.ToString();
                        nodeevent.AppendChild(subnodeday);

                        // <time>_time_</time>
                        XmlNode subnodetime = doc.CreateElement("time");
                        subnodetime.InnerText = mevent.Time;
                        nodeevent.AppendChild(subnodetime);

                        // <location>_loc_</location>
                        XmlNode subnodeloc = doc.CreateElement("location");
                        subnodeloc.InnerText = mevent.Location;
                        nodeevent.AppendChild(subnodeloc);

                        // <importance>_importance_</importance>
                        XmlNode subnodeimp = doc.CreateElement("importance");
                        subnodeimp.InnerText = mevent.Importance.ToString();
                        nodeevent.AppendChild(subnodeimp);

                        // <power>_power_</power>
                        XmlNode subnodepower = doc.CreateElement("power");
                        subnodepower.InnerText = mevent.Power.ToString();
                        nodeevent.AppendChild(subnodepower);
                    }

                    // <\event>
                    module.AppendChild(nodeevent);

                    saveLibDoc(doc);
                }
            }
        }