Format for painting chart header
Exemplo n.º 1
0
 private static void AppendHeader(IDictionary <string, string> headers, string key, string value)
 {
     if (!string.IsNullOrEmpty(value))
     {
         headers.TrySetValue(HeaderFormat.FormatWith(key), value);
     }
 }
Exemplo n.º 2
0
        private bool AreHeadersEqual(string currentHeader)
        {
            var unixEndingHeader       = currentHeader.Replace("\r\n", "\n");
            var unixEndingHeaderFormat = HeaderFormat.Replace("\r\n", "\n");

            return(IsRegularExpression
                ? Regex.IsMatch(unixEndingHeader, unixEndingHeaderFormat)
                : unixEndingHeader.Equals(unixEndingHeaderFormat, StringComparison.Ordinal));
        }
        protected bool AreHeadersEqual(string currentHeader)
        {
            var unixEndingHeader       = currentHeader.Replace("\r\n", "\n");
            var unixEndingHeaderFormat = HeaderFormat.Replace("\r\n", "\n").Replace("\\r\\n", "\n");

            if (!IsRegularExpression && !unixEndingHeaderFormat.EndsWith("\n"))
            {
                // In standard text mode, we want to be sure that the matched header is on its own
                // line, with nothing else on the same line.
                unixEndingHeaderFormat += "\n";
            }
            return(IsRegularExpression
                ? Regex.IsMatch(unixEndingHeader, unixEndingHeaderFormat)
                : unixEndingHeader.StartsWith(unixEndingHeaderFormat, StringComparison.Ordinal));
        }
Exemplo n.º 4
0
        public SchedulerControl()
        {
            InitializeComponent();

            HeaderOneHeight     = 32;
            HeaderTwoHeight     = 20;
            BarSpacing          = 32;
            BarHeight           = 20;
            MajorWidth          = 140;
            MinorWidth          = 20;
            TimeResolution      = TimeResolution.Day;
            this.DoubleBuffered = true;

            viewPort = new ControlViewport(this)
            {
                WheelDelta = BarSpacing
            };
            modelGenerator = new SchedulerModelGenerator(this, viewPort, models);
            painter        = new SchedulerPainter(this, models, viewPort);
            //AllowTaskDragDrop = true;
            ShowSlack      = true;
            ShowTaskLabels = true;
            this.Dock      = DockStyle.Fill;
            this.Margin    = new Padding(0, 0, 0, 0);
            this.Padding   = new Padding(0, 0, 0, 0);
            HeaderFormat   = new HeaderFormat()
            {
                Color         = Brushes.Black,
                Border        = new Pen(SystemColors.ActiveBorder),
                GradientLight = SystemColors.ButtonHighlight,
                GradientDark  = SystemColors.ButtonFace
            };
            MajorLabelFormat = new HeaderLabelFormat()
            {
                Font      = Font,
                Color     = HeaderFormat.Color,
                Margin    = 3,
                TextAlign = ChartTextAlign.MiddleCenter
            };
            MinorLabelFormat = new HeaderLabelFormat()
            {
                Font      = Font,
                Color     = HeaderFormat.Color,
                Margin    = 3,
                TextAlign = ChartTextAlign.MiddleCenter
            };
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initialize a new instance of HeaderPaintEventArgs with the editable default font and header format
 /// </summary>
 public HeaderPaintEventArgs(Graphics graphics, Rectangle clipRect, Chart chart, Font font, HeaderFormat format)
     : base(graphics, clipRect, chart)
 {
     this.Font = font;
         this.Format = format;
 }
Exemplo n.º 6
0
            public void ReceivedNewByteInHeader(byte b, ref bool errorInHeader, ref bool HeaderInProgress)
            {
                if (receivedBytes == -1)
                {
                    if (b == Convert.ToByte(ControlBytes.ZPAD))
                    {
                        return;
                    }

                    else if (b == Convert.ToByte(ControlBytes.ZDLE))
                    {
                        receivedBytes = 0;
                    }
                    return;
                }

                if (lastByteisZDLE)
                {
                    b = Convert.ToByte(b ^ 64);
                    lastByteisZDLE = false;
                }
                else if (b == Convert.ToByte(ControlBytes.ZDLE))
                {
                    lastByteisZDLE = true;
                    return;
                }

                if (receivedBytes == 0)
                { // Find the type
                    if (b == Convert.ToByte(ControlBytes.ZBIN))
                    {
                        format = HeaderFormat.Bin16;
                    }
                    else if (b == Convert.ToByte(ControlBytes.ZBINC))
                    {
                        format = HeaderFormat.Bin32;
                    }
                    else if (b == Convert.ToByte(ControlBytes.ZHEX))
                    {
                        format = HeaderFormat.Hex;
                    }

                    //format = (HeaderFormat)Enum.Parse(typeof(HeaderFormat), ((int)b).ToString());
                    receivedBytes++;
                    tempoHex = "";
                    return;
                }

                if (format == HeaderFormat.Bin16)
                {
                    switch (receivedBytes)
                    {
                    case 1:

                        type = (HeaderType)Enum.Parse(typeof(HeaderType), ((int)b).ToString());
                        receivedBytes++;
                        return;

                    case 2:
                    case 3:
                    case 4:
                    case 5:
                        args[receivedBytes - 2] = b;
                        receivedBytes++;
                        break;

                    case 6:
                        crc[receivedBytes - 6] = b;
                        receivedBytes++;
                        break;

                    case 7:
                        crc[receivedBytes - 6] = b;
                        receivedBytes++;
                        if (CheckCRC(type, args, crc))
                        {
                            valid            = true;
                            errorInHeader    = false;
                            HeaderInProgress = false;
                        }
                        else
                        {
                            valid         = false;
                            errorInHeader = true;
                        }
                        break;
                    }
                }
                else if (format == HeaderFormat.Hex)
                {
                    switch (receivedBytes)
                    {
                    case 1:
                        if (string.IsNullOrEmpty(tempoHex))
                        {
                            tempoHex = ((char)b).ToString();
                        }
                        else
                        {
                            tempoHex += ((char)b).ToString();
                            type      = (HeaderType)Enum.Parse(typeof(HeaderType), tempoHex);
                            tempoHex  = "";
                            receivedBytes++;
                        }
                        return;

                    case 2:
                    case 3:
                    case 4:
                    case 5:
                        if (string.IsNullOrEmpty(tempoHex))
                        {
                            tempoHex = ((char)b).ToString();
                        }
                        else
                        {
                            tempoHex += ((char)b).ToString();
                            int a1 = Convert.ToInt32(tempoHex, 16);
                            args[receivedBytes - 2] = Convert.ToByte(a1);
                            tempoHex = "";
                            receivedBytes++;
                        }
                        return;

                    case 6:
                    case 7:
                        if (string.IsNullOrEmpty(tempoHex))
                        {
                            tempoHex = ((char)b).ToString();
                        }
                        else
                        {
                            tempoHex += ((char)b).ToString();
                            int a1 = Convert.ToInt32(tempoHex, 16);
                            crc[receivedBytes - 6] = Convert.ToByte(a1);
                            tempoHex = "";
                            receivedBytes++;
                        }
                        if (CheckCRC(type, args, crc))
                        {
                            valid = true;
                        }
                        else
                        {
                            valid = false;
                        }
                        break;

                    case 8:
                    case 9:
                    case 10:
                        if (b == Convert.ToByte(ControlBytes.CR))
                        {
                            receivedBytes++;
                            HeaderInProgress = false;
                            return;
                        }
                        else if (b == Convert.ToByte(ControlBytes.LF))
                        {
                            receivedBytes++;
                            HeaderInProgress = false;
                            return;
                        }
                        else if (b == Convert.ToByte(ControlBytes.XON))
                        {
                            receivedBytes++;
                            HeaderInProgress = false;
                            return;
                        }
                        else
                        {
                            throw new Exception("CR LR XON expeced after an Hex header!");
                        }
                        break;
                    }
                }
                else if (format == HeaderFormat.Bin32)
                {
                    switch (receivedBytes)
                    {
                    case 1:
                        type = (HeaderType)Enum.Parse(typeof(HeaderType), ((int)b).ToString());
                        receivedBytes++;
                        return;

                    case 2:
                    case 3:
                    case 4:
                    case 5:
                        args[receivedBytes - 2] = b;
                        receivedBytes++;
                        break;

                    case 6:
                    case 7:
                    case 8:
                    case 9:
                        crc[receivedBytes - 6] = b;
                        receivedBytes++;
                        throw new Exception("CRC check not implemented for binary 32bits headers");
                        HeaderInProgress = false;
                        break;
                    }
                }
            }
Exemplo n.º 7
0
        private void CALENDAR_Load(object sender, EventArgs e)
        {
            CONNECTION.open_connection();
            ProjectManager _mManager = new ProjectManager();

            using (MySqlDataAdapter da = new MySqlDataAdapter("SELECT room.room_name,room.current_status,guest.first_name,guest.last_name,reservation.arrival_date,reservation.depature_Date,room_packages.package_name FROM reservation,recerved_rooms,room_packages,room,guest WHERE reservation.reservation_id = recerved_rooms.reservation_no AND recerved_rooms.room_id = room.room_id AND room.room_package_id = room_packages.room_package_id AND guest.guest_id = reservation.guest_id AND reservation.depature_Date >= CURDATE()", CONNECTION.CON))
            {
                DataTable getRooms = new DataTable();
                da.Fill(getRooms);
                if (getRooms.Rows.Count > 0)
                {
                    int      a     = 0;
                    MyTask[] rooms = new MyTask[getRooms.Rows.Count];
                    foreach (DataRow dr in getRooms.Rows)
                    {
                        double duration, start;
                        rooms[a]           = new MyTask(_mManager);
                        rooms[a].TaskColor = getRoomColor(dr["current_status"].ToString());
                        rooms[a].Name      = "Room " + dr["room_name"].ToString();

                        if (Convert.ToDateTime(dr["arrival_date"].ToString()).Date < DateTime.Now.Date)
                        {
                            duration = (Convert.ToDateTime(dr["depature_Date"].ToString()).Date - DateTime.Today.Date).TotalDays;
                            start    = 0;
                        }
                        else
                        {
                            duration = (Convert.ToDateTime(dr["depature_Date"].ToString()).Date - Convert.ToDateTime(dr["arrival_date"].ToString()).Date).TotalDays;
                            start    = (Convert.ToDateTime(dr["arrival_date"].ToString()).Date - DateTime.Today.Date).TotalDays;
                        }

                        _mManager.Add(rooms[a]);
                        _mManager.SetStart(rooms[a], (int)start);
                        _mManager.SetDuration(rooms[a], (int)duration);
                        gnattChartRoom.PaintHeader += (s, ee) =>
                        {
                            var headerFormat = new HeaderFormat();
                            headerFormat = ee.Format;
                            headerFormat.GradientLight = Color.Silver;
                            headerFormat.GradientDark  = Color.Gray;
                            ee.Format = headerFormat;
                        };
                        gnattChartRoom.PaintTask += (s, ee) =>
                        {
                            MyTask ptask = ee.Task as MyTask;
                            if (ptask != null)
                            {
                                var format = new TaskFormat();
                                format          = ee.Format;
                                format.BackFill = new SolidBrush(ptask.TaskColor);
                                format.Border   = new Pen(new SolidBrush(ptask.TaskColor));
                                ee.Format       = format;
                            }
                        };
                        gnattChartRoom.SetToolTip(rooms[a], dr["first_name"].ToString() + " " + dr["last_name"].ToString() + "\nRoom " + dr["room_name"].ToString() + "\n" + dr["current_status"].ToString());
                        a++;
                    }

                    gnattChartRoom.Init(_mManager);
                    gnattChartRoom.CreateTaskDelegate = delegate() { return(new MyTask(_mManager)); };
                }
            }
        }
Exemplo n.º 8
0
 public HeaderFormatOptions UseExpanded()
 {
     HeaderFormat = HeaderFormat.Expanded;
     return(this);
 }
Exemplo n.º 9
0
 public HeaderFormatOptions UseCondensed()
 {
     HeaderFormat = HeaderFormat.Condensed;
     return(this);
 }