示例#1
0
        private void SaveNewFormat()
        {
            btnNewFormat.Text          = "New Format";
            btnClearFormat.Enabled     = false;
            btnSetFormat.Enabled       = false;
            btnCancelNewFormat.Visible = false;
            grpDisplayFormat.Enabled   = false;
            trvDataSources.Enabled     = true;
            lstDisplayFormats.Enabled  = true;

            ViewDisplayFormat format = null;

            format = new ViewDisplayFormat()
            {
                Name      = txtDfName.Text,
                Format    = txtDfFormat.Text,
                Sample    = txtSample.Text,
                Alignment = rbLeft.Checked ? HorizontalAlignment.Left : rbCenter.Checked ? HorizontalAlignment.Center : HorizontalAlignment.Right
            };

            int maxWidth;

            if (Int32.TryParse(txtDfMaxWidth.Text, out maxWidth))
            {
                format.MaxWidth = maxWidth;
            }

            MapService.DisplayFormats.Add(format);

            ClearFormatDisplay();

            LoadDisplayFormats(MapService.DisplayFormats);

            lstDisplayFormats.SelectedItem = format;
        }
示例#2
0
        private void lstDisplayFormats_SelectedIndexChanged(object sender, EventArgs e)
        {
            UpdateMapPanelState();

            ViewDisplayFormat format = (ViewDisplayFormat)lstDisplayFormats.SelectedItem;

            DisplayFormat(format);

            UpdateUsedByList(format);
        }
示例#3
0
        private void DeleteFormat(ViewDisplayFormat format)
        {
            foreach (var item in MapService.Map.Where(v => v.Value.Name == format.Name).ToList())
            {
                MapService.Map.Remove(item);
            }

            MapService.DisplayFormats.Remove(format);

            LoadDisplayFormats(MapService.DisplayFormats);

            DisplayDataSources(DataSources);
        }
示例#4
0
        private void UpdateNodeState(TreeNode node, ViewDisplayFormat format)
        {
            int imageIndex;

            if (format == null)
            {
                imageIndex = NoFormatImageIndex;
            }
            else
            {
                imageIndex = (int)format.Alignment;
            }

            node.ImageIndex         = imageIndex;
            node.SelectedImageIndex = imageIndex;
        }
示例#5
0
        private void DisplayFormat(ViewDisplayFormat format)
        {
            ClearFormatDisplay();

            if (format == null)
            {
                return;
            }

            txtDfName.Text   = format.Name;
            txtDfFormat.Text = format.Format;

            rbLeft.Checked   = (format.Alignment == HorizontalAlignment.Left);
            rbCenter.Checked = (format.Alignment == HorizontalAlignment.Center);
            rbRight.Checked  = (format.Alignment == HorizontalAlignment.Right);

            txtSample.Text     = format.Sample;
            txtDfMaxWidth.Text = format.MaxWidth.ToString();
        }
示例#6
0
        private void SaveEditedFormat()
        {
            btnNewFormat.Text          = "New Format";
            btnClearFormat.Enabled     = false;
            btnSetFormat.Enabled       = false;
            btnCancelNewFormat.Visible = false;
            grpDisplayFormat.Enabled   = false;
            trvDataSources.Enabled     = true;
            lstDisplayFormats.Enabled  = true;

            ViewDisplayFormat format = (ViewDisplayFormat)lstDisplayFormats.SelectedItem;

            var originalName = format.Name;

            format.Name      = txtDfName.Text;
            format.Format    = txtDfFormat.Text;
            format.Sample    = txtSample.Text;
            format.Alignment = rbLeft.Checked ? HorizontalAlignment.Left : rbCenter.Checked ? HorizontalAlignment.Center : HorizontalAlignment.Right;
            int maxWidth;

            if (Int32.TryParse(txtDfMaxWidth.Text, out maxWidth))
            {
                format.MaxWidth = maxWidth;
            }

            ClearFormatDisplay();

            LoadDisplayFormats(MapService.DisplayFormats);

            lstDisplayFormats.SelectedIndex = -1;

            lstDisplayFormats.SelectedItem = format;

            _isEditMode = false;

            foreach (var item in MapService.Map.Where(v => v.Value.Name == originalName).ToList())
            {
                MapService.Map[item.Key] = format;
            }

            DisplayDataSources(DataSources);
        }
示例#7
0
        private void BeginEditFormat(ViewDisplayFormat format)
        {
            ClearFormatDisplay();

            btnNewFormat.Text          = "Save";
            btnClearFormat.Enabled     = false;
            btnSetFormat.Enabled       = false;
            btnCancelNewFormat.Visible = true;
            trvDataSources.Enabled     = false;
            lstDisplayFormats.Enabled  = false;

            lblDfMaxWidth.Visible = true;
            txtDfMaxWidth.Visible = true;

            grpDisplayFormat.Enabled = true;

            DisplayFormat(format);

            _isEditMode = true;
        }
示例#8
0
        private void UpdateUsedByList(ViewDisplayFormat format)
        {
            lstUsedBy.Items.Clear();
            lstUsedBy.DisplayMember = "Title";

            if (format == null)
            {
                return;
            }

            foreach (var item in MapService.Map.Where(m => m.Value.Name == format.Name))
            {
                var usedByItem = new UsedByItem()
                {
                    Name           = format.Name,
                    Title          = $"{item.Key.DataFeed} {item.Key.Path.Replace("\\", " ")}",
                    ViewDataMember = item.Key
                };

                lstUsedBy.Items.Add(usedByItem);
            }
        }
示例#9
0
        protected virtual IList <ViewListColumn> CreateViewListColumnList()
        {
            var viewListColumns = new List <ViewListColumn>();

            int i = 0;

            foreach (ViewDataMember viewDataMember in CreateViewContext.ViewDataMembers)
            {
                if (!_mapService.Map.ContainsKey(viewDataMember) || _mapService.Map[viewDataMember].Name == "Default")
                {
                    var newViewDisplayFormat = new ViewDisplayFormat()
                    {
                        Name = viewDataMember.Name
                    };

                    if (viewDataMember.Type.Name.ToString() == "System.String")
                    {
                        newViewDisplayFormat.Sample = "Abcdefg Hijklmnop";
                    }
                    else if (viewDataMember.Type.Name.ToString() == "System.Int32")
                    {
                        newViewDisplayFormat.Sample = "12345";
                        newViewDisplayFormat.Format = "###";
                    }
                    else if (viewDataMember.Type.Name.ToString() == "System.Decimal" || viewDataMember.Type.Name.ToString() == "System.Double")
                    {
                        newViewDisplayFormat.Sample = "123.456";
                        newViewDisplayFormat.Format = "###.##0";
                    }
                    else if (viewDataMember.Type.Name.ToString() == "System.TimeSpan")
                    {
                        newViewDisplayFormat.Sample = "12:34:56.78";
                        newViewDisplayFormat.Format = "hh\\:mm\\:ss.fff";
                    }
                    else
                    {
                        Console.WriteLine($"Unrecognized field type: {viewDataMember.Type.Name.ToString()}, field: {viewDataMember.Name}");
                    }

                    _mapService.Map[viewDataMember] = newViewDisplayFormat;
                }

                var viewDisplayFormat = _mapService.Map[viewDataMember];

                viewListColumns.Add(new ViewListColumn()
                {
                    Index         = i,
                    Alignment     = viewDisplayFormat.ContentAlignment,
                    Caption       = viewDataMember.Caption,
                    Format        = viewDisplayFormat.Format,
                    Sample        = viewDisplayFormat.Sample,
                    Width         = viewDisplayFormat.MaxWidth,
                    Type          = viewDataMember.Type.Name,
                    ConvertedType = viewDataMember.ConvertedType.Name,
                    SortType      = i == 0 ? SortType.Ascending : SortType.None,
                    DataMember    = viewDataMember.Name,
                    DataFullPath  = viewDataMember.Path,
                    DataFeed      = viewDataMember.DataFeed,
                    DataFeedAssemblyQualifiedName = viewDataMember.DataFeedType.AssemblyQualifiedName,
                    DataFeedFullName = viewDataMember.DataFeedType.FullName
                });

                i++;
            }

            _mapService.Save();

            return(viewListColumns);
        }
 public virtual void AddNewFormatToMap(ViewDataMember member, ViewDisplayFormat format)
 {
     DisplayFormats.Add(format);
     Map[member] = format;
 }
示例#11
0
        protected virtual void BuildDataSourceTreeView(TreeNode dataSourceNode, ViewDataSource dataSource)
        {
            bool mapAdded = false;

            foreach (ViewDataMember viewDataMember in dataSource.Fields)
            {
                var dataFormatMapItem = new DataFormatMapItem()
                {
                    DataMember = viewDataMember
                };

                var fieldNode = new TreeNode(viewDataMember.Caption);

                if (!MapService.Map.ContainsKey(viewDataMember) || MapService.Map[viewDataMember].Name == "Default")
                {
                    var displayFormat = MapService.DisplayFormats.FirstOrDefault(f => f.Name == viewDataMember.Name);

                    if (displayFormat != null)
                    {
                        MapService.Map[viewDataMember] = displayFormat;
                    }
                    else
                    {
                        var newViewDisplayFormat = new ViewDisplayFormat()
                        {
                            Name = viewDataMember.Name
                        };

                        if (viewDataMember.Type.Name.ToString() == "String")
                        {
                            newViewDisplayFormat.Sample = "Abcdefg Hijklmnop";
                        }
                        else if (viewDataMember.Type.Name.ToString() == "Int32")
                        {
                            newViewDisplayFormat.Sample = "12345";
                            newViewDisplayFormat.Format = "###";
                        }
                        else if (viewDataMember.Type.Name.ToString() == "Decimal" || viewDataMember.Type.Name.ToString() == "Double")
                        {
                            newViewDisplayFormat.Sample = "123.456";
                            newViewDisplayFormat.Format = "###.##0";
                        }
                        else if (viewDataMember.Type.Name.ToString() == "TimeSpan")
                        {
                            newViewDisplayFormat.Sample = "12:34:56.78";
                            newViewDisplayFormat.Format = "hh\\:mm\\:ss.fff";
                        }
                        else if (viewDataMember.Type.Name.ToString() == "Boolean")
                        {
                            newViewDisplayFormat.Sample = "True";
                        }
                        else if (viewDataMember.Type.Name.ToString() == "Boolean")
                        {
                            newViewDisplayFormat.Sample = "True";
                        }
                        else if (viewDataMember.Type.Name.ToString() == "TrackState")
                        {
                            newViewDisplayFormat.Sample = "Caution";
                        }
                        else if (viewDataMember.Type.Name.ToString() == "SeriesType")
                        {
                            newViewDisplayFormat.Sample = "XFinity";
                        }
                        else if (viewDataMember.Type.Name.ToString() == "RunType")
                        {
                            newViewDisplayFormat.Sample = "Practice";
                        }
                        else if (viewDataMember.Type.Name.ToString() == "VehicleStatus")
                        {
                            newViewDisplayFormat.Sample = "OnTrack";
                        }
                        else
                        {
                            Console.WriteLine($"Unrecognized field type: {viewDataMember.Type.Name.ToString()}, field: {viewDataMember.Name}");
                        }

                        MapService.AddNewFormatToMap(viewDataMember, newViewDisplayFormat);

                        mapAdded = true;
                    }
                }

                var viewDisplayFormat = MapService.Map[viewDataMember];

                dataFormatMapItem.DisplayFormat = viewDisplayFormat;

                fieldNode.Tag = dataFormatMapItem;

                UpdateNodeState(fieldNode, viewDisplayFormat);

                dataSourceNode.Nodes.Add(fieldNode);
            }

            if (mapAdded)
            {
                MapService.Save();
            }

            foreach (ViewDataSource dataList in dataSource.Lists)
            {
                var listNode = new TreeNode(dataList.Caption + "[]")
                {
                    Tag                = dataList,
                    ImageIndex         = ClosedFolderImageIndex,
                    SelectedImageIndex = ClosedFolderImageIndex,
                };

                BuildDataSourceTreeView(listNode, dataList);

                dataSourceNode.Nodes.Add(listNode);
            }

            foreach (ViewDataSource dataList in dataSource.NestedClasses)
            {
                var listNode = new TreeNode(dataList.Caption)
                {
                    Tag                = dataList,
                    ImageIndex         = ClosedFolderImageIndex,
                    SelectedImageIndex = ClosedFolderImageIndex,
                };

                BuildDataSourceTreeView(listNode, dataList);

                dataSourceNode.Nodes.Add(listNode);
            }
        }