public MephGroupBox()
 {
     SetStyle(ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
     BackColor      = Color.Transparent;
     ForeColor      = Color.FromArgb(205, 205, 205);
     Size           = new Size(174, 115);
     _HeaderLine    = HeaderLine.Enabled;
     DoubleBuffered = true;
 }
Example #2
0
        public static void HandleHeaderLine(ref MdLine currentLine, string line, List <MdLine> mdLines)
        {
            if (currentLine.Content != null)
            {
                mdLines.Add(currentLine);
            }
            var headerTag  = TagHelper.DetermineCurrentTag(line, 0, headerTags);
            var headerLine = new HeaderLine(headerTag);

            headerLine.AddContent(line);
            mdLines.Add(headerLine);
            currentLine = new TextLine();
        }
 public override void Render()
 {
     //set Arrow Properties
     foreach (var arrow in Arrows)
     {
         arrow.Fill            = Fill;
         arrow.StrokeThickness = StrokeThickness;
         arrow.Thickness       = Thickness;
         arrow.Stroke          = Stroke;
         arrow.Visibility      = Visibility;
     }
     //set headLine Properties
     HeaderLine.Fill            = Fill;
     HeaderLine.StrokeThickness = StrokeThickness;
     HeaderLine.Thickness       = Thickness;
     HeaderLine.Stroke          = Stroke;
     HeaderLine.Visibility      = Visibility;
     //
     HeaderLine.Render();
     Arrows.ForEach(e => e.Render());
 }
        public override void SetScale(double value)
        {
            HeaderLine.SetScale(value);
            HeaderLine.SetTranslate(0, -Height * value + Height);
            Arrows.ForEach(e => e.Remove());

            Spacings = 10 * value;
            var span = Math.Sqrt(
                Math.Pow(StartPoint.X - EndPoint.X, 2) +
                Math.Pow(StartPoint.Y - EndPoint.Y, 2));

            var spaces = Split.Equal(span * value, Spacings);

            foreach (var space in spaces)
            {
                var arrow = new Arrow(GCanvas, new Point(StartPoint.X + space, StartPoint.Y), Height * value);
                arrow.Rotate(180);

                Arrows.Add(arrow);
            }
            HeaderLine.Remove();
            Render();
        }
Example #5
0
        public Header ConfigureColumn(string name, short startIndex, short endIndex)
        {
            var columnString = HeaderLine.Substring(startIndex, endIndex);

            if (!name.Contains(columnString.Trim()))
            {
                throw new ColumnNotFound($"A coluna {name} não foi encontrada no arquivo");
            }
            try
            {
                HeaderLine = HeaderLine.Substring(endIndex);
                Column column = new Column(name);
                column.StartIndex = 0;
                column.EndIndex   = endIndex;
                column.Index      = Container.Count + 1;
                Container.Add(name, column);
            }
            catch (Exception ex)
            {
                throw new ParseColumnException($"Falha ao ler a coluna {name}.\nOs seguintes erros ocorreram:\n{ex.Message}", ex);
            }
            return(this);
        }
 public override void Hide()
 {
     HeaderLine.Hide();
     Arrows.ForEach(e => e.Hide());
 }
        protected virtual void SetupHeaderView()
        {
            MenuLine?.SetBackgroundColor(ColorConstants.BackgroundGray);
            BottomHeaderLine?.SetBackgroundColor(ColorConstants.BlackColor);
            HeaderRootView?.SetBackgroundColor(ColorConstants.BlackColor);
            ContentView?.SetBackgroundColor(ColorConstants.BackroundContent);
            HeaderLeftImageView?.SetSelected(ColorConstants.BlackColor);
            HeaderRightImageView?.SetSelected(ColorConstants.BlackColor);

            HeaderLine?.SetBackgroundColor(ColorConstants.BlackColor);

            if (CounterTextView != null)
            {
                CounterTextView.Visibility = ViewState.Invisible;
            }

            switch (HeaderAreaAction)
            {
            case HeaderAreaActionType.Nothing:

                HeaderLeftImageView?.SetImageFromResource(null);
                HeaderRightImageView?.SetImageFromResource(null);
                if (!HeaderLeftTouchArea.IsNull())
                {
                    HeaderLeftTouchArea.Click  -= BackAction;
                    HeaderRightTouchArea.Click -= Shop;
                }

                break;

            case HeaderAreaActionType.Back:

                HeaderLeftImageView?.SetImageFromResource(DrawableConstants.BackIcon);
                HeaderLeftImageView?.SetSelected(ColorConstants.SelectorHome);

                if (HeaderLeftImageView != null)
                {
                    HeaderLeftImageView.Click -= BackAction;
                    HeaderLeftImageView.Click += BackAction;
                }

                HeaderRightImageView?.SetImageFromResource(null);

                if (!HeaderTextView.IsNull())
                {
                    HeaderTextView.Text = HeaderText;
                    HeaderTextView.SetTextColor(ColorConstants.WhiteColor);
                    HeaderTextView.SetFont(FontsConstant.OpenSansBold, FontsConstant.Size18);
                }
                if (!HeaderLeftTouchArea.IsNull() && !HeaderRightTouchArea.IsNull())
                {
                    HeaderLeftTouchArea.Click  -= BackAction;
                    HeaderLeftTouchArea.Click  += BackAction;
                    HeaderRightTouchArea.Click -= Shop;
                }
                break;

            case HeaderAreaActionType.Menu:

                if (!HeaderLeftImageView.IsNull())
                {
                    HeaderLeftImageView?.SetImageFromResource(DrawableConstants.MenuIcon);
                    HeaderLeftImageView?.SetSelected(ColorConstants.SelectorHome);
                    if (HeaderLeftImageView != null)
                    {
                        HeaderLeftImageView.Click -= MenuAction;
                        HeaderLeftImageView.Click += MenuAction;
                    }
                }

                HeaderRightImageView?.SetImageFromResource(null);

                if (!HeaderTextView.IsNull())
                {
                    HeaderTextView.Text = HeaderText;
                    HeaderTextView.SetTextColor(ColorConstants.WhiteColor);
                    HeaderTextView.SetFont(FontsConstant.OpenSansBold, FontsConstant.Size18);
                }

                break;

            case HeaderAreaActionType.Shop:

                HeaderLeftImageView?.SetImageFromResource(DrawableConstants.MenuIcon);
                HeaderLeftImageView?.SetSelected(ColorConstants.SelectorHome);
                if (HeaderLeftImageView != null)
                {
                    HeaderLeftImageView.Click -= MenuAction;
                    HeaderLeftImageView.Click += MenuAction;
                }


                HeaderRightImageView?.SetImageFromResource(DrawableConstants.ShopIcon);
                HeaderRightImageView?.SetSelected(ColorConstants.SelectorHome);

                HeaderRightImageView.Click -= Shop;
                HeaderRightImageView.Click += Shop;

                if (!CounterTextView.IsNull())
                {
                    CounterTextView.Visibility = ViewState.Visible;
                    CounterTextView.Text       = OrderManager.Instance.CurrentOrderCount.ToString();

                    OrderManager.Instance.ChangeOrder -= Instance_ChangeOrder;
                    OrderManager.Instance.ChangeOrder += Instance_ChangeOrder;
                    CounterTextView.SetTextColor(ColorConstants.WhiteColor);

                    CounterTextView.SetBackgroundColor(ColorConstants.SelectorHome, 8);
                }

                if (!HeaderTextView.IsNull())
                {
                    HeaderTextView.Text = HeaderText;
                    HeaderTextView.SetTextColor(ColorConstants.WhiteColor);
                    HeaderTextView.SetFont(FontsConstant.OpenSansBold, FontsConstant.Size18);
                }

                if (!HeaderLeftTouchArea.IsNull() && !HeaderRightTouchArea.IsNull())
                {
                    HeaderLeftTouchArea.Click -= MenuAction;
                    HeaderLeftTouchArea.Click += MenuAction;

                    HeaderRightTouchArea.Click -= Shop;
                    HeaderRightTouchArea.Click += Shop;
                }

                break;
            }
        }
 private LineInfo ProcessTaskItem(DesignerActionList list, DesignerActionItem item)
 {
     Line line = null;
     if (item is DesignerActionMethodItem)
     {
         line = new MethodLine(this._serviceProvider, this);
     }
     else if (item is DesignerActionPropertyItem)
     {
         DesignerActionPropertyItem item2 = (DesignerActionPropertyItem) item;
         PropertyDescriptor propDesc = TypeDescriptor.GetProperties(list)[item2.MemberName];
         if (propDesc == null)
         {
             throw new InvalidOperationException(System.Design.SR.GetString("DesignerActionPanel_CouldNotFindProperty", new object[] { item2.MemberName, list.GetType().FullName }));
         }
         TypeDescriptorContext context = new TypeDescriptorContext(this._serviceProvider, propDesc, list);
         UITypeEditor editor = (UITypeEditor) propDesc.GetEditor(typeof(UITypeEditor));
         bool standardValuesSupported = propDesc.Converter.GetStandardValuesSupported(context);
         if (editor == null)
         {
             if (propDesc.PropertyType == typeof(bool))
             {
                 if (IsReadOnlyProperty(propDesc))
                 {
                     line = new TextBoxPropertyLine(this._serviceProvider, this);
                 }
                 else
                 {
                     line = new CheckBoxPropertyLine(this._serviceProvider, this);
                 }
             }
             else if (standardValuesSupported)
             {
                 line = new EditorPropertyLine(this._serviceProvider, this);
             }
             else
             {
                 line = new TextBoxPropertyLine(this._serviceProvider, this);
             }
         }
         else
         {
             line = new EditorPropertyLine(this._serviceProvider, this);
         }
     }
     else
     {
         if (!(item is DesignerActionTextItem))
         {
             return null;
         }
         if (item is DesignerActionHeaderItem)
         {
             line = new HeaderLine(this._serviceProvider, this);
         }
         else
         {
             line = new TextLine(this._serviceProvider, this);
         }
     }
     return new LineInfo(list, item, line);
 }
Example #9
0
        /// <summary>
        ///     Deserializes data from a CSV
        /// </summary>
        /// <returns>
        ///     An IEnumerable of type T
        /// </returns>
        /// <param name="Reader">Reader with CSV data.</param>
        /// <param name="DeserializationOptions"> Options for deserialization.</param>
        public static IEnumerable <T> Deserialize <T>(StreamReader Reader, CsvDeserializationOptions DeserializationOptions) where T : class, new()
        {
            string[] Columns;
            string[] Rows;
            try
            {
                string FirstLine = Reader.ReadLine();
                string HeaderLine;
                if (Regex.IsMatch(FirstLine, "^sep=(.)$", RegexOptions.IgnoreCase))
                {
                    DeserializationOptions.Separator = FirstLine.Last();
                    HeaderLine = Reader.ReadLine();
                }
                else
                {
                    HeaderLine = FirstLine;
                }


                Columns = HeaderLine.Split(DeserializationOptions.Separator);

                Rows = Reader
                       .ReadToEnd()
                       .Split(new string[] { Environment.NewLine }, StringSplitOptions.None)
                ;
            }
            catch (Exception ex)
            {
                throw new CsvFormatException("Invalid CSV file.", ex);
            }

            var Members = GetMembers(typeof(T), DeserializationOptions);

            var Data = new List <T>();

            for (var Row = 0; Row < Rows.Length; Row++)
            {
                var Line = Rows[Row];

                if (DeserializationOptions.IgnoreEmptyLines && string.IsNullOrWhiteSpace(Line))
                {
                    continue;
                }

                if (!DeserializationOptions.IgnoreEmptyLines && string.IsNullOrWhiteSpace(Line))
                {
                    throw new CsvFormatException(string.Format("Empty line at line number: {0}", Row));
                }

                var Parts = Line.Split(DeserializationOptions.Separator);

                var firstColumnIndex = DeserializationOptions.UseRowNumbers ? 1 : 0;
                if (Parts.Length == firstColumnIndex + 1 && Parts[firstColumnIndex] != null &&
                    Parts[firstColumnIndex] == "EOF")
                {
                    break;
                }

                var Item = new T();

                var Start = DeserializationOptions.UseRowNumbers ? 1 : 0;
                for (var i = Start; i < Parts.Length; i++)
                {
                    string Value;
                    string Column;
                    try
                    {
                        Value  = Parts[i].Trim();
                        Column = Columns[i];
                    }
                    catch (IndexOutOfRangeException)
                    {
                        throw new CsvFormatException(string.Format(@"Error: on line: {0}", Row));
                    }

                    // Ignore the rownumber column, unless T has such a member.
                    if (Column.Equals(DeserializationOptions.RowNumberColumnTitle) &&
                        !Members.Any(a => a.Name.Equals(DeserializationOptions.RowNumberColumnTitle)))
                    {
                        continue;
                    }
                    var p = Members.FirstOrDefault(a => a.Name.Equals(Column, StringComparison.InvariantCultureIgnoreCase));

                    // Member not founnd on T, ignore column.
                    if (p == null)
                    {
                        continue;
                    }

                    if (DeserializationOptions.UseTextQualifier)
                    {
                        if (Value.IndexOf("\"") == 0)
                        {
                            Value = Value.Substring(1);
                        }

                        if (Value[Value.Length - 1].ToString() == "\"")
                        {
                            Value = Value.Substring(0, Value.Length - 1);
                        }
                    }

                    if (p is PropertyInfo)
                    {
                        var converter      = TypeDescriptor.GetConverter((p as PropertyInfo).PropertyType);
                        var convertedvalue = converter.ConvertFromString(null, DeserializationOptions.Culture, Value);
                        (p as PropertyInfo).SetValue(Item, convertedvalue);
                    }
                    else if (p is FieldInfo)
                    {
                        var converter      = TypeDescriptor.GetConverter((p as FieldInfo).FieldType);
                        var convertedvalue = converter.ConvertFromString(null, DeserializationOptions.Culture, Value);
                        (p as FieldInfo).SetValue(Item, convertedvalue);
                    }
                    else
                    {
                        continue;
                    }
                }

                Data.Add(Item);
            }

            return(Data);
        }
        /// <summary>
        /// Process file and update the file progress.
        /// </summary>
        /// <param name="fileProgress">The file progress.</param>
        /// <returns></returns>
        private bool ProcessFile(FileProgress fileProgress)
        {
            try
            {
                using (var fs = new FileStream(fileProgress.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    using (var inputFile = new StreamReader(fs))
                    {
                        // search for the header line
                        string inputLine;
                        var    foundHeader = false;
                        var    headerValidationErrorMessage = string.Empty;
                        var    metadataFound = false;
                        while ((inputLine = inputFile.ReadLine()) != null)
                        {
                            if (inputLine.StartsWith("Report"))
                            {
                                metadataFound = true;
                            }

                            if (DataContextObject.DatasetItem.ContentType.Name.ToUpper() == ImportTypeName.ToUpper())
                            {
                                if (!inputLine.ToUpper().StartsWith(HeaderLine.SubStrBefore(",").ToUpper()) && metadataFound)
                                {
                                    continue; // Found metadata
                                }
                                metadataFound = false;
                            }

                            ////fileProgress.LinesDone++;
                            //fileProgress.PercentComplete = fileProgress.LinesDone * 100 / fileProgress.TotalLines;
                            //AppendLogLinesDone(fileProgress.LinesDone);

                            if (ValidateFileHeader(inputLine.ToUpper().Trim(), fileProgress, out headerValidationErrorMessage))
                            {
                                // Found the file token in the header. Ready to start import.
                                foundHeader = true;
                                break;
                            }

                            if (fileProgress.LinesDone > 50)
                            {
                                break;
                            }
                        }

                        if (!foundHeader && !string.IsNullOrEmpty(headerValidationErrorMessage))
                        {
                            // Didn't find file token in input file before EOF
                            MessageBox.Show(AppendLog(headerValidationErrorMessage), "Error importing file");
                            return(false);
                        }

                        AppendLog(string.Format("Header row found. Continuing from line {0}.", fileProgress.LinesDone));

                        // TODO: move this to a service
                        // save owner before inserting all rows
                        DataContextObject.CurrentImportType = DataContextObject.GetTargetByName(DataContextObject.SelectedDataType.DataTypeName);

                        // import each line
                        while ((inputLine = inputFile.ReadLine()) != null)
                        {
                            try
                            {
                                if (_lineFunction(inputLine))
                                {
                                    fileProgress.LinesProcessed++;
                                }
                                else
                                {
                                    fileProgress.LinesDuplicated++;
                                }
                            }
                            catch (Exception e)
                            {
                                fileProgress.LinesErrors++;
                                AppendLog("Error : " + e.Message);
                            }
                            finally
                            {
                                fileProgress.LinesDone++;
                                // fileProgress.PercentComplete = (fileProgress.LinesDone * 100) / fileProgress.TotalLines;
                                AppendLogLinesDone(fileProgress.LinesDone);
                            }
                        }
                    }
                AppendLog(fileProgress.LinesDone + " lines processed.");

                //DataContextObject.DatasetItem.IsFinished = true;
                //DataContextObject.SaveImportEntry(DataContextObject.DatasetItem);
            }
            catch (Exception e)
            {
                MessageBox.Show(AppendLog("Error : " + e.Message), string.Format("Error importing file [{0}]", fileProgress.FileName));
                return(false);
            }

            return(true);
        }
 public HeaderLineTest()
 {
     this.definition = DefinitionFactory.Make();
     this.comment    = CommentFactory.Make();
     this.headerLine = new HeaderLine(this.comment, this.definition);
 }