Example #1
0
        private void BuildColumns()
        {
            // Hidden expander column
            TreeViewColumn col = new TreeViewColumn();

            col.Visible = false;
            AppendColumn(col);
            ExpanderColumn = col;

            source_column        = new TreeViewColumn();
            source_column.Sizing = TreeViewColumnSizing.Autosize;

            uint xpad = 2;

            // Special renderer for header rows; hidden for normal source rows
            header_renderer = new CellRendererText()
            {
                Xpad      = xpad,
                Ypad      = 4,
                Ellipsize = Pango.EllipsizeMode.End,
                Weight    = (int)Pango.Weight.Bold,
                Variant   = Pango.Variant.SmallCaps
            };

            // Renderer for source rows; hidden for header rows
            source_renderer      = new SourceRowRenderer();
            source_renderer.Xpad = xpad;

            source_column.PackStart(header_renderer, true);
            source_column.SetCellDataFunc(header_renderer, new Gtk.CellLayoutDataFunc((layout, cell, model, iter) => {
                var type = (SourceModel.EntryType)model.GetValue(iter, (int)SourceModel.Columns.Type);
                header_renderer.Visible = type == SourceModel.EntryType.Group;
                source_renderer.Visible = type == SourceModel.EntryType.Source;
                if (type == SourceModel.EntryType.Group)
                {
                    var source = model.GetValue(iter, (int)SourceModel.Columns.Source) as Source;
                    header_renderer.Visible = true;
                    header_renderer.Text    = source.Name;
                }
                else
                {
                    header_renderer.Visible = false;
                }
            }));

            int width, height;

            Gtk.Icon.SizeLookup(IconSize.Menu, out width, out height);
            source_renderer.RowHeight = RowHeight.Get();
            source_renderer.RowHeight = height;

            source_renderer.Ypad = (uint)RowPadding.Get();
            source_renderer.Ypad = 2;
            source_column.PackStart(source_renderer, true);
            source_column.SetCellDataFunc(source_renderer, new CellLayoutDataFunc(SourceRowRenderer.CellDataHandler));
            AppendColumn(source_column);

            HeadersVisible = false;
        }
Example #2
0
        private void BuildColumns()
        {
            // Hidden expander column
            TreeViewColumn col = new TreeViewColumn();

            col.Visible = false;
            AppendColumn(col);
            ExpanderColumn = col;

            focus_column       = new TreeViewColumn();
            renderer           = new SourceRowRenderer();
            renderer.RowHeight = RowHeight.Get();
            renderer.Padding   = RowPadding.Get();
            focus_column.PackStart(renderer, true);
            focus_column.SetCellDataFunc(renderer, new CellLayoutDataFunc(SourceRowRenderer.CellDataHandler));
            AppendColumn(focus_column);

            HeadersVisible = false;
        }
Example #3
0
        private void BuildColumns()
        {
            // Hidden expander column
            TreeViewColumn col = new TreeViewColumn();

            col.Visible = false;
            AppendColumn(col);
            ExpanderColumn = col;

            source_column        = new TreeViewColumn();
            source_column.Sizing = TreeViewColumnSizing.Autosize;

            uint xpad = 2;

            // Special renderer for header rows; hidden for normal source rows
            header_renderer = new CellRendererText()
            {
                Xpad      = xpad,
                Ypad      = 4,
                Ellipsize = Pango.EllipsizeMode.End,
                Weight    = (int)Pango.Weight.Bold,
                Variant   = Pango.Variant.SmallCaps
            };

            // Renderer for source rows; hidden for header rows
            source_renderer      = new SourceRowRenderer();
            source_renderer.Xpad = xpad;

            source_column.PackStart(header_renderer, true);
            source_column.SetCellDataFunc(header_renderer, new Gtk.CellLayoutDataFunc((layout, cell, model, iter) => {
                if (model == null)
                {
                    throw new ArgumentNullException("model");
                }

                // be paranoid about the values returned from model.GetValue(), they may be null or have unexpected types, see bgo#683359
                var obj_type = model.GetValue(iter, (int)SourceModel.Columns.Type);
                if (obj_type == null || !(obj_type is SourceModel.EntryType))
                {
                    var source      = model.GetValue(iter, (int)SourceModel.Columns.Source) as Source;
                    var source_name = source == null ? "some source" : String.Format("source {0}", source.Name);

                    Log.ErrorFormat(
                        "SourceView of {0} could not render its source column because its type value returned {1} from the iter",
                        source_name, obj_type == null ? "null" : String.Format("an instance of {0}", obj_type.GetType().FullName));

                    header_renderer.Visible = false;
                    source_renderer.Visible = false;

                    return;
                }

                var type = (SourceModel.EntryType)obj_type;
                header_renderer.Visible = type == SourceModel.EntryType.Group;
                source_renderer.Visible = type == SourceModel.EntryType.Source;
                if (type == SourceModel.EntryType.Group)
                {
                    var source = (Source)model.GetValue(iter, (int)SourceModel.Columns.Source);
                    header_renderer.Visible = true;
                    header_renderer.Text    = source.Name;
                }
                else
                {
                    header_renderer.Visible = false;
                }
            }));

            int width, height;

            Gtk.Icon.SizeLookup(IconSize.Menu, out width, out height);
            source_renderer.RowHeight = RowHeight.Get();
            source_renderer.RowHeight = height;

            source_renderer.Ypad = (uint)RowPadding.Get();
            source_renderer.Ypad = 2;
            source_column.PackStart(source_renderer, true);
            source_column.SetCellDataFunc(source_renderer, new CellLayoutDataFunc(SourceRowRenderer.CellDataHandler));
            AppendColumn(source_column);

            HeadersVisible = false;
        }
Example #4
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            PropertyDescriptor property = context.DataContext.GetProperties()[ExcelCreate.GetExcelAppTag];
            Excel::Application excelApp = property.GetValue(context.DataContext) as Excel::Application;

            try
            {
                string cellName_Begin   = CellName_Begin.Get(context);
                string cellName_End     = CellName_End.Get(context);
                int    cellRow_Begin    = CellRow_Begin.Get(context);
                int    cellColumn_Begin = CellColumn_Begin.Get(context);
                int    cellRow_End      = CellRow_End.Get(context);
                int    cellColumn_End   = CellColumn_End.Get(context);
                double rowHeight        = RowHeight.Get(context);
                double colWidth         = ColWidth.Get(context);
                Int32  fontSize         = FontSize.Get(context);
                string sheetName        = SheetName.Get(context);

                Excel::_Worksheet sheet = null;
                if (sheetName == null)
                {
                    sheet = excelApp.ActiveSheet;
                }
                else
                {
                    sheet = excelApp.ActiveWorkbook.Sheets[sheetName];
                }

                Excel::Range range1, range2;
                range1 = cellName_Begin == null ? sheet.Cells[cellRow_Begin, cellColumn_Begin] : sheet.Range[cellName_Begin];
                range2 = cellName_End == null ? sheet.Cells[cellRow_End, cellColumn_End] : sheet.Range[cellName_End];
                Excel::Range range = sheet.Range[range1, range2];

                /*对齐设置*/
                if ((int)_AlignStyle != 0)
                {
                    range.HorizontalAlignment = (AlignEnum)_AlignStyle;
                }

                /*字体*/
                range.Font.Bold      = isBold;
                range.Font.Italic    = isItalic;
                range.Font.Underline = isUnderLine;
                if (Font != 0)
                {
                    range.Font.Name = ConvertFont(Font.ToString());
                }
                range.Font.Size = fontSize;

                if ((int)_FontColor != 0)
                {
                    range.Font.ColorIndex = (int)_FontColor;
                }

                /*填充色*/
                if ((int)_CellColor != 0)
                {
                    range.Interior.ColorIndex = (int)_CellColor;
                }

                /*行列宽度*/
                range.RowHeight   = rowHeight;
                range.ColumnWidth = colWidth;

                /*边框*/
                if ((int)_BorderStyle != 0)
                {
                    switch ((int)_BorderType)
                    {
                    case 0:
                    {
                        range.Borders.LineStyle = (int)_BorderStyle;
                        break;
                    }

                    case 1:
                    {
                        range.Borders[Excel.XlBordersIndex.xlEdgeLeft].LineStyle = (int)_BorderStyle;
                        break;
                    }

                    case 2:
                    {
                        range.Borders[Excel.XlBordersIndex.xlEdgeRight].LineStyle = (int)_BorderStyle;
                        break;
                    }

                    case 3:
                    {
                        range.Borders[Excel.XlBordersIndex.xlEdgeTop].LineStyle = (int)_BorderStyle;
                        break;
                    }

                    case 4:
                    {
                        range.Borders[Excel.XlBordersIndex.xlEdgeBottom].LineStyle = (int)_BorderStyle;
                        break;
                    }

                    default:
                        break;
                    }
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(sheet);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(range);
                sheet = null;
                range = null;
                GC.Collect();
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "EXCEL区域设置执行过程出错", e.Message);
                new CommonVariable().realaseProcessExit(excelApp);
            }
            m_Delegate = new runDelegate(Run);
            return(m_Delegate.BeginInvoke(callback, state));
        }