private static Drawing.Rectangle GetRectangle(Shapes.XFormCells xform)
 {
     var pin = new Drawing.Point(xform.PinX.Result, xform.PinY.Result);
     var locpin = new Drawing.Point(xform.LocPinX.Result, xform.LocPinY.Result);
     var size = new Drawing.Size(xform.Width.Result, xform.Height.Result);
     return new Drawing.Rectangle(pin - locpin, size);
 }
 public TextBlock(Drawing.Size size, string text)
 {
     this.Text = text;
     this.Size = size;
     this.TextBlockCells = new Text.TextBlockCells();
     this.ParagraphCells = new Text.ParagraphCells();
     this.FormatCells = new Shapes.FormatCells();
     this.CharacterCells = new Text.CharacterCells();
 }
 public FormPage()
 {
     this.Size = new Drawing.Size(8.5, 11);
     this.Margin = new Drawing.Margin(0.5, 0.5, 0.5, 0.5);
     this.DefaultFont = "Segoe UI";
     this.BodyTextSize = 8.0;
     this.BodyParaSpacingAfter = 0.0;
     this.TitleTextSize = 15.0;
 }
Exemple #4
0
        private static void SetSize(IVisio.Page page, Drawing.Size size)
        {
            var page_cells = new PageCells();

            page_cells.PageHeight = size.Height;
            page_cells.PageWidth  = size.Width;
            var pageupdate = new ShapeSheet.Update();

            pageupdate.SetFormulas(page_cells);
            pageupdate.Execute(page.PageSheet);
        }
 private void InitializeComponent()
 {
     btnCancel          = new Button();
     btnOkay            = new Button();
     editAllCHR0Editor1 = new EditAllCHR0Editor();
     SuspendLayout();
     //
     // btnCancel
     //
     btnCancel.Anchor                  = AnchorStyles.Bottom | AnchorStyles.Right;
     btnCancel.DialogResult            = DialogResult.Cancel;
     btnCancel.Location                = new Drawing.Point(325, 344);
     btnCancel.Name                    = "btnCancel";
     btnCancel.Size                    = new Drawing.Size(75, 23);
     btnCancel.TabIndex                = 2;
     btnCancel.Text                    = "&Cancel";
     btnCancel.UseVisualStyleBackColor = true;
     btnCancel.Click                  += new EventHandler(btnCancel_Click);
     //
     // btnOkay
     //
     btnOkay.Anchor   = AnchorStyles.Bottom | AnchorStyles.Right;
     btnOkay.Location = new Drawing.Point(244, 344);
     btnOkay.Name     = "btnOkay";
     btnOkay.Size     = new Drawing.Size(75, 23);
     btnOkay.TabIndex = 1;
     btnOkay.Text     = "&Okay";
     btnOkay.UseVisualStyleBackColor = true;
     btnOkay.Click += new EventHandler(btnOkay_Click);
     //
     // editAllCHR0Editor1
     //
     editAllCHR0Editor1.Dock     = DockStyle.Top;
     editAllCHR0Editor1.Location = new Drawing.Point(0, 0);
     editAllCHR0Editor1.Name     = "editAllCHR0Editor1";
     editAllCHR0Editor1.Size     = new Drawing.Size(404, 338);
     editAllCHR0Editor1.TabIndex = 3;
     //
     // EditAllDialog
     //
     AcceptButton = btnOkay;
     CancelButton = btnCancel;
     ClientSize   = new Drawing.Size(404, 374);
     Controls.Add(editAllCHR0Editor1);
     Controls.Add(btnCancel);
     Controls.Add(btnOkay);
     FormBorderStyle = FormBorderStyle.FixedToolWindow;
     Name            = "EditAllDialog";
     ShowIcon        = false;
     ShowInTaskbar   = false;
     StartPosition   = FormStartPosition.CenterParent;
     Text            = "Edit All Animations";
     ResumeLayout(false);
 }
 private static Drawing.Size GetSize(IVisio.Page page)
 {
     var query = new ShapeSheet.Query.CellQuery();
     var col_height = query.AddCell(ShapeSheet.SRCConstants.PageHeight,"PageHeight");
     var col_width = query.AddCell(ShapeSheet.SRCConstants.PageWidth,"PageWidth");
     var results = query.GetResults<double>(page.PageSheet);
     double height = results[col_height];
     double width = results[col_width];
     var s = new Drawing.Size(width, height);
     return s;
 }
 public BrstmConverterDialog()
 {
     InitializeComponent();
     ddlEncoding.Items.Clear();
     ddlEncoding.Items.Add(WaveEncoding.ADPCM);
     ddlEncoding.Items.Add(WaveEncoding.PCM16);
     ddlEncoding.SelectedItem = PreviousEncoding;
     tmrUpdate.Interval       = 1000 / 60;
     dlgOpen.Filter           = "PCM Audio (*.wav)|*.wav";
     MaximumSize = new Drawing.Size(int.MaxValue, 216);
 }
Exemple #8
0
        private static Drawing.Size GetSize(IVisio.Page page)
        {
            var    query      = new ShapeSheet.Query.CellQuery();
            var    col_height = query.AddCell(ShapeSheet.SRCConstants.PageHeight, "PageHeight");
            var    col_width  = query.AddCell(ShapeSheet.SRCConstants.PageWidth, "PageWidth");
            var    results    = query.GetResults <double>(page.PageSheet);
            double height     = results[col_height];
            double width      = results[col_width];
            var    s          = new Drawing.Size(width, height);

            return(s);
        }
        void Init()
        {
            var skcontrol = new SKControl();

            skcontrol.PaintSurfaceAction = ((surface) => Tests.PaintStuff(surface));

            Title = "SKControl Demo (CPU Renderer)";

            ClientSize = new Drawing.Size(500, 500);

            Content = skcontrol;
        }
Exemple #10
0
        internal static Drawing.Size GetSize(IVisio.Page page)
        {
            var query      = new ShapeSheetQuery();
            var col_height = query.AddCell(ShapeSheet.SrcConstants.PageHeight, nameof(ShapeSheet.SrcConstants.PageHeight));
            var col_width  = query.AddCell(ShapeSheet.SrcConstants.PageWidth, nameof(ShapeSheet.SrcConstants.PageWidth));

            var    results = query.GetResults <double>(page.PageSheet);
            double height  = results.Cells[col_height];
            double width   = results.Cells[col_width];
            var    s       = new Drawing.Size(width, height);

            return(s);
        }
Exemple #11
0
 protected ToolStripItem()
 {
     Enabled      = true;
     Font         = SystemFonts.uwfArial_12;
     ForeColor    = Color.FromArgb(64, 64, 64);
     HoverColor   = Color.FromArgb(64, 200, 200, 200);
     HoverPadding = new Size(2, 2);
     ImageColor   = Color.White;
     Name         = "toolStripItem";
     Padding      = new Forms.Padding(8, 0, 8, 0);
     Size         = new Drawing.Size(160, 24);
     TextAlign    = ContentAlignment.MiddleLeft;
 }
Exemple #12
0
        internal void init(int id, Node <T> parent, Drawing.Size size, T data)
        {
            this.Id     = id;
            this.Size   = size;
            this.Data   = data;
            this.Parent = parent;

            this._child_list    = new List <Node <T> >();
            this.left_neighbor  = null;
            this.right_neighbor = null;
            this.Position       = new Drawing.Point(0, 0);
            this._is_collapsed  = false;
        }
Exemple #13
0
        /// <param name="constrainingSize">The custom-sized area for a control.</param>
        /// <returns>An ordered pair of type System.Drawing.Size representing the width and height of a rectangle.</returns>
        public override Size GetPreferredSize(Drawing.Size constrainingSize)
        {
            if (!this.Stretch || this.IsOnOverflow || Owner.Orientation == Orientation.Vertical)
            {
                return(base.GetPreferredSize(constrainingSize));
            }

            Int32 width = this.Owner.DisplayRectangle.Width;
            Int32 stretchControlCount = 0;

            if (this.Owner.OverflowButton.Visible)
            {
                width -= this.Owner.OverflowButton.Width + this.Owner.OverflowButton.Margin.Horizontal;
            }

            foreach (ToolStripItem item in this.Owner.Items)
            {
                if (item.IsOnOverflow)
                {
                    continue;
                }

                if (item is ToolStripTextBoxEx)
                {
                    stretchControlCount++;
                    width -= item.Margin.Horizontal;
                }

                else
                {
                    width -= item.Width + item.Margin.Horizontal;
                }
            }

            if (stretchControlCount > 1)
            {
                width /= stretchControlCount;
            }

            if (width < this.DefaultSize.Width)
            {
                width = this.DefaultSize.Width;
            }

            var baseSize = base.GetPreferredSize(constrainingSize);

            baseSize.Width = width;

            return(baseSize);
        }
Exemple #14
0
 public ToolStripItem()
 {
     Enabled      = true;
     ForeColor    = Color.FromArgb(64, 64, 64);
     HoverColor   = Color.FromArgb(64, 200, 200, 200);
     HoverPadding = new Rectangle(2, 2, -4, -4);
     ImageColor   = Color.White;
     Name         = "toolStripItem";
     Padding      = new Forms.Padding(8, 0, 8, 0);
     Size         = new Drawing.Size(160, 24);
     TextAlign    = new StringFormat()
     {
         Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Near
     };
 }
        public Button()
        {
            BackgroundImageLayout = ImageLayout.Center;
            Font              = new Drawing.Font("Arial", 12);
            ForeColor         = Color.FromArgb(64, 64, 64);
            ImageColor        = Color.White;
            NormalColor       = Color.FromArgb(234, 234, 234);
            NormalBorderColor = Color.FromArgb(172, 172, 172);
            HoverColor        = Color.FromArgb(223, 238, 252);
            HoverBorderColor  = Color.FromArgb(126, 180, 234);
            TextAlign         = ContentAlignment.MiddleCenter;
            Size              = new Drawing.Size(75, 23);

            currentBackColor = NormalColor;
        }
Exemple #16
0
        public CheckBox()
        {
            BackColor          = Color.White;
            BorderColor        = Color.FromArgb(112, 112, 112);
            BorderHoverColor   = Color.FromArgb(51, 153, 255);
            BorderDisableColor = Color.FromArgb(188, 188, 188);
            CanSelect          = true;
            DisableColor       = Color.FromArgb(230, 230, 230);
            ForeColor          = Color.Black;
            HoverColor         = Color.FromArgb(243, 249, 255);
            Size      = new Drawing.Size(128, 17);
            TextAlign = ContentAlignment.MiddleLeft;

            Click += CheckBox_Click;
        }
Exemple #17
0
            public FormFileInfo(string path)
            {
#if UNITY_STANDALONE
                Size      = new Drawing.Size(320, 120);
                Location  = new Point(Screen.PrimaryScreen.WorkingArea.Width / 2 - Width / 2, Screen.PrimaryScreen.WorkingArea.Height / 2 - Height / 2);
                Resizable = false;
                Text      = "Properties: ";

                if (System.IO.File.Exists(path) == false)
                {
                    return;
                }

                var    info   = new System.IO.FileInfo(path);
                var    bytes  = info.Length;
                string sbytes = bytes.ToString() + " bytes";
                if (bytes >= 1000000000)
                {
                    sbytes = (bytes / 1000000000) + " gb";
                }
                if (bytes >= 1000000)
                {
                    sbytes = (bytes / 1000000) + " mb";
                }
                else if (bytes >= 1000)
                {
                    sbytes = (bytes / 1000) + " kb";
                }

                Label labelSize = new Label();
                labelSize.Location = new Point(16, 32);
                labelSize.Text     = "Size: " + sbytes;
                Controls.Add(labelSize);

                Label labelCreationDate = new Label();
                labelCreationDate.Location = new Point(16, 64);
                labelCreationDate.Text     = "Date creation: " + info.CreationTime.ToString("dd.MM.yyyy");
                Controls.Add(labelCreationDate);

                Label labelModDate = new Label();
                labelModDate.Location = new Point(16, 86);
                labelModDate.Text     = "Date modified: " + info.LastWriteTime.ToString();
                Controls.Add(labelModDate);

                string fileName = System.IO.Path.GetFileName(path);
                Text += fileName;
#endif
            }
        public void FitShapeToText(IList <IVisio.Shape> target_shapes)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var shapes = this.GetTargetShapes2D(target_shapes);

            if (shapes.Count < 1)
            {
                return;
            }

            var application = this.Client.Application.Get();
            var active_page = application.ActivePage;
            var shapeids    = shapes.Select(s => s.ID).ToList();

            using (var undoscope = this.Client.Application.NewUndoScope("FitShapeToText"))
            {
                // Calculate the new sizes for each shape
                var new_sizes = new List <Drawing.Size>(shapeids.Count);
                foreach (var shape in shapes)
                {
                    var text_bounding_box = shape.GetBoundingBox(Microsoft.Office.Interop.Visio.VisBoundingBoxArgs.visBBoxUprightText).Size;
                    var wh_bounding_box   = shape.GetBoundingBox(Microsoft.Office.Interop.Visio.VisBoundingBoxArgs.visBBoxUprightWH).Size;

                    double max_w    = System.Math.Max(text_bounding_box.Width, wh_bounding_box.Width);
                    double max_h    = System.Math.Max(text_bounding_box.Height, wh_bounding_box.Height);
                    var    max_size = new Drawing.Size(max_w, max_h);
                    new_sizes.Add(max_size);
                }

                var src_width  = ShapeSheet.SRCConstants.Width;
                var src_height = ShapeSheet.SRCConstants.Height;

                var update = new ShapeSheet.Update();
                for (int i = 0; i < new_sizes.Count; i++)
                {
                    var shapeid  = shapeids[i];
                    var new_size = new_sizes[i];
                    update.SetFormula((short)shapeid, src_width, new_size.Width);
                    update.SetFormula((short)shapeid, src_height, new_size.Height);
                }

                update.Execute(active_page);
            }
        }
Exemple #19
0
        public void FitShapeToText(TargetShapes targets)
        {
            this._client.Application.AssertApplicationAvailable();
            this._client.Document.AssertDocumentAvailable();

            var shapes = targets.ResolveShapes2D(this._client);

            if (shapes.Shapes.Count < 1)
            {
                return;
            }

            var application = this._client.Application.Get();
            var active_page = application.ActivePage;
            var shapeids    = shapes.Shapes.Select(s => s.ID).ToList();

            using (var undoscope = this._client.Application.NewUndoScope("Fit Shape To Text"))
            {
                // Calculate the new sizes for each shape
                var new_sizes = new List <Drawing.Size>(shapeids.Count);
                foreach (var shape in shapes.Shapes)
                {
                    var text_bounding_box = shape.GetBoundingBox(IVisio.VisBoundingBoxArgs.visBBoxUprightText).Size;
                    var wh_bounding_box   = shape.GetBoundingBox(IVisio.VisBoundingBoxArgs.visBBoxUprightWH).Size;

                    double max_w    = System.Math.Max(text_bounding_box.Width, wh_bounding_box.Width);
                    double max_h    = System.Math.Max(text_bounding_box.Height, wh_bounding_box.Height);
                    var    max_size = new Drawing.Size(max_w, max_h);
                    new_sizes.Add(max_size);
                }

                var src_width  = VisioAutomation.ShapeSheet.SRCConstants.Width;
                var src_height = VisioAutomation.ShapeSheet.SRCConstants.Height;

                var writer = new FormulaWriterSIDSRC();
                for (int i = 0; i < new_sizes.Count; i++)
                {
                    var shapeid  = shapeids[i];
                    var new_size = new_sizes[i];
                    writer.SetFormula((short)shapeid, src_width, new_size.Width);
                    writer.SetFormula((short)shapeid, src_height, new_size.Height);
                }

                writer.Commit(active_page);
            }
        }
Exemple #20
0
        public void ResizeToFitContents(Drawing.Size bordersize, bool zoom_to_page)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var application = this.Client.Application.Get();

            using (var undoscope = this.Client.Application.NewUndoScope("Resize Page to Fit Contents"))
            {
                var active_page = application.ActivePage;
                active_page.ResizeToFitContents(bordersize);
                if (zoom_to_page)
                {
                    this.Client.View.Zoom(Zoom.ToPage);
                }
            }
        }
Exemple #21
0
        public void SetSize(Drawing.Size new_size)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var application = this.Client.Application.Get();

            using (var undoscope = this.Client.Application.NewUndoScope("Set Page Size"))
            {
                var active_page = application.ActivePage;
                var page_sheet  = active_page.PageSheet;
                var update      = new ShapeSheet.Update(2);
                update.SetFormula(ShapeSheet.SRCConstants.PageWidth, new_size.Width);
                update.SetFormula(ShapeSheet.SRCConstants.PageHeight, new_size.Height);
                update.Execute(page_sheet);
            }
        }
        public void SetSize(Drawing.Size new_size)
        {
            this._client.Application.AssertApplicationAvailable();
            this._client.Document.AssertDocumentAvailable();

            var application = this._client.Application.Get();

            using (var undoscope = this._client.Application.NewUndoScope("Set Page Size"))
            {
                var active_page = application.ActivePage;
                var page_sheet  = active_page.PageSheet;
                var writer      = new FormulaWriterSRC(2);
                writer.SetFormula(VisioAutomation.ShapeSheet.SRCConstants.PageWidth, new_size.Width);
                writer.SetFormula(VisioAutomation.ShapeSheet.SRCConstants.PageHeight, new_size.Height);
                writer.Commit(page_sheet);
            }
        }
Exemple #23
0
        public Button()
        {
            BackColor             = Color.FromArgb(234, 234, 234);
            BackgroundImageLayout = ImageLayout.Center;
            BorderColor           = Color.FromArgb(172, 172, 172);
            BorderHoverColor      = Color.FromArgb(126, 180, 234);
            BorderSelectColor     = Color.FromArgb(51, 153, 255);
            CanSelect             = true;
            Font       = new Drawing.Font("Arial", 12);
            ForeColor  = Color.FromArgb(64, 64, 64);
            ImageColor = Color.White;
            HoverColor = Color.FromArgb(223, 238, 252);
            TextAlign  = ContentAlignment.MiddleCenter;
            Size       = new Drawing.Size(75, 23);

            currentBackColor = BackColor;
        }
        public MaskedTextBoxTextEditorDropDown(MaskedTextBox maskedTextBox)
        {
            _cloneMtb      = MaskedTextBoxDesigner.GetDesignMaskedTextBox(maskedTextBox);
            _errorProvider = new ErrorProvider();
            ((System.ComponentModel.ISupportInitialize)(_errorProvider)).BeginInit();

            SuspendLayout();
            //
            // maskedTextBox
            //
            _cloneMtb.Dock = DockStyle.Fill;

            // Include prompt and literals always so editor can process the text value in a consistent way.
            _cloneMtb.TextMaskFormat = MaskFormat.IncludePromptAndLiterals;

            // Escape prompt, literals and space so input is not rejected due to one of these characters.
            _cloneMtb.ResetOnPrompt = true;
            _cloneMtb.SkipLiterals  = true;
            _cloneMtb.ResetOnSpace  = true;

            _cloneMtb.Name               = "MaskedTextBoxClone";
            _cloneMtb.TabIndex           = 0;
            _cloneMtb.MaskInputRejected += new MaskInputRejectedEventHandler(maskedTextBox_MaskInputRejected);
            _cloneMtb.KeyDown           += new KeyEventHandler(maskedTextBox_KeyDown);

            //
            // errorProvider
            //
            _errorProvider.BlinkStyle       = ErrorBlinkStyle.NeverBlink;
            _errorProvider.ContainerControl = this;

            //
            // MaskedTextBoxTextEditorDropDown
            //
            Controls.Add(_cloneMtb);

            BackColor   = Drawing.SystemColors.Control;
            BorderStyle = BorderStyle.FixedSingle;
            Name        = "MaskedTextBoxTextEditorDropDown";
            Padding     = new Padding(16);
            Size        = new Drawing.Size(100, 52);
            ((System.ComponentModel.ISupportInitialize)(_errorProvider)).EndInit();
            ResumeLayout(false);
            PerformLayout();
        }
Exemple #25
0
        public void SetSize(double?width, double?height)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            if (!width.HasValue && !height.HasValue)
            {
                // nothing to do
                return;
            }

            var old_size = this.GetSize();
            var w        = width.GetValueOrDefault(old_size.Width);
            var h        = height.GetValueOrDefault(old_size.Height);
            var new_size = new Drawing.Size(w, h);

            this.SetSize(new_size);
        }
 private void InitializeComponent()
 {
     btnOkay      = new Button();
     richTextBox1 = new RichTextBox();
     SuspendLayout();
     //
     // btnOkay
     //
     btnOkay.Anchor   = AnchorStyles.Bottom | AnchorStyles.Right;
     btnOkay.Location = new Drawing.Point(594, 575);
     btnOkay.Name     = "btnOkay";
     btnOkay.Size     = new Drawing.Size(75, 23);
     btnOkay.TabIndex = 1;
     btnOkay.Text     = "&Okay";
     btnOkay.UseVisualStyleBackColor = true;
     btnOkay.Click += new EventHandler(btnOkay_Click);
     //
     // richTextBox1
     //
     richTextBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom
                           | AnchorStyles.Left
                           | AnchorStyles.Right;
     richTextBox1.Font = new Drawing.Font("Microsoft Sans Serif", 9F, Drawing.FontStyle.Regular,
                                          Drawing.GraphicsUnit.Point, 0);
     richTextBox1.ForeColor  = Drawing.Color.Black;
     richTextBox1.Location   = new Drawing.Point(12, 12);
     richTextBox1.Name       = "richTextBox1";
     richTextBox1.ReadOnly   = true;
     richTextBox1.ScrollBars = RichTextBoxScrollBars.ForcedVertical;
     richTextBox1.Size       = new Drawing.Size(657, 557);
     richTextBox1.TabIndex   = 2;
     //
     // ModelViewerHelp
     //
     AcceptButton = btnOkay;
     ClientSize   = new Drawing.Size(681, 610);
     Controls.Add(richTextBox1);
     Controls.Add(btnOkay);
     Name          = "ModelViewerHelp";
     ShowInTaskbar = false;
     StartPosition = FormStartPosition.CenterParent;
     Text          = "Viewer Help";
     ResumeLayout(false);
 }
Exemple #27
0
        public static void SnapCorner(IVisio.Page page, TargetShapeIDs target, Drawing.Size snapsize, SnapCornerPosition corner)
        {
            // First caculate the new transforms
            var snap_grid    = new SnappingGrid(snapsize);
            var input_xfrms  = ShapeXFormData.Get(page, target);
            var output_xfrms = new List <VisioAutomation.Drawing.Point>(input_xfrms.Count);

            foreach (var input_xfrm in input_xfrms)
            {
                var old_rect         = input_xfrm.GetRectangle();
                var old_lower_left   = old_rect.LowerLeft;
                var new_lower_left   = snap_grid.Snap(old_lower_left);
                var new_pin_position = ArrangeHelper.GetPinPositionForCorner(input_xfrm, new_lower_left, corner);
                var output_xfrm      = new VisioAutomation.Drawing.Point(new_pin_position.X, new_pin_position.Y);
                output_xfrms.Add(output_xfrm);
            }

            ModifyPinPositions(page, target.ShapeIDs, output_xfrms);
        }
Exemple #28
0
        public Drawing.Size GetSize()
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var application = this.Client.Application.Get();
            var active_page = application.ActivePage;


            var    query      = new ShapeSheet.Query.CellQuery();
            var    col_height = query.AddCell(ShapeSheet.SRCConstants.PageHeight, "PageHeight");
            var    col_width  = query.AddCell(ShapeSheet.SRCConstants.PageWidth, "PageWidth");
            var    results    = query.GetResults <double>(active_page.PageSheet);
            double height     = results[col_height];
            double width      = results[col_width];
            var    s          = new Drawing.Size(width, height);

            return(s);
        }
        public static void SnapCorner(IVisio.Page page, IList <int> shapeids, Drawing.Size snapsize, SnapCornerPosition corner)
        {
            // First caculate the new transforms
            var snap_grid    = new Drawing.SnappingGrid(snapsize);
            var input_xfrms  = Shapes.XFormCells.GetCells(page, shapeids);
            var output_xfrms = new List <Shapes.XFormCells>(input_xfrms.Count);

            foreach (var input_xfrm in input_xfrms)
            {
                var old_rect       = ArrangeHelper.GetRectangle(input_xfrm);
                var old_lower_left = old_rect.LowerLeft;
                var new_lower_left = snap_grid.Snap(old_lower_left);
                var output_xfrm    = ArrangeHelper._SnapCorner(corner, new_lower_left, input_xfrm);
                output_xfrms.Add(output_xfrm);
            }

            // Now apply them
            ArrangeHelper.update_xfrms(page, shapeids, output_xfrms);
        }
        public Drawing.Size GetSize()
        {
            this._client.Application.AssertApplicationAvailable();
            this._client.Document.AssertDocumentAvailable();

            var application = this._client.Application.Get();
            var active_page = application.ActivePage;


            var query      = new ShapeSheetQuery();
            var col_height = query.AddCell(VisioAutomation.ShapeSheet.SrcConstants.PageHeight, nameof(VisioAutomation.ShapeSheet.SrcConstants.PageHeight));
            var col_width  = query.AddCell(VisioAutomation.ShapeSheet.SrcConstants.PageWidth, nameof(VisioAutomation.ShapeSheet.SrcConstants.PageWidth));

            var    results = query.GetResults <double>(active_page.PageSheet);
            double height  = results.Cells[col_height];
            double width   = results.Cells[col_width];
            var    s       = new Drawing.Size(width, height);

            return(s);
        }
        public static void SnapSize(IVisio.Page page, IList <int> shapeids, Drawing.Size snapsize, Drawing.Size minsize)
        {
            var input_xfrms  = Shapes.XFormCells.GetCells(page, shapeids);
            var output_xfrms = new List <Shapes.XFormCells>(input_xfrms.Count);

            var grid = new Drawing.SnappingGrid(snapsize);

            foreach (var input_xfrm in input_xfrms)
            {
                // First snap the size to the grid
                double old_w        = input_xfrm.Width.Result;
                double old_h        = input_xfrm.Height.Result;
                var    input_size   = new Drawing.Size(old_w, old_h);
                var    snapped_size = grid.Snap(input_size);

                // then account for any minum size requirements
                double new_w       = System.Math.Max(snapped_size.Width, minsize.Width);
                double new_h       = System.Math.Max(snapped_size.Height, minsize.Height);
                var    output_size = new Drawing.Size(new_w, new_h);

                // Output the new size for the shape if the size of the shape changed
                bool different_widths  = (old_w != new_w);
                bool different_heights = (old_h != new_h);
                if (different_widths || different_heights)
                {
                    var output_xfrm = new Shapes.XFormCells();
                    if (different_widths)
                    {
                        output_xfrm.Width = output_size.Width;
                    }
                    if (different_heights)
                    {
                        output_xfrm.Height = output_size.Height;
                    }
                    output_xfrms.Add(output_xfrm);
                }
            }

            // Now apply the updates to the sizes
            ArrangeHelper.update_xfrms(page, shapeids, output_xfrms);
        }
Exemple #32
0
        public void SnapSize(IList <IVisio.Shape> target_shapes, Drawing.Size snapsize, Drawing.Size minsize)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var shapes = this.GetTargetShapes2D(target_shapes);

            if (shapes.Count < 1)
            {
                return;
            }

            var shapeids    = shapes.Select(s => s.ID).ToList();
            var application = this.Client.Application.Get();

            using (var undoscope = this.Client.Application.NewUndoScope("SnapSize"))
            {
                var active_page = application.ActivePage;
                ArrangeHelper.SnapSize(active_page, shapeids, snapsize, minsize);
            }
        }
        public void SnapSize(TargetShapes targets, Drawing.Size snapsize, Drawing.Size minsize)
        {
            this._client.Application.AssertApplicationAvailable();
            this._client.Document.AssertDocumentAvailable();

            var shapes = targets.ResolveShapes2D(this._client);

            if (shapes.Shapes.Count < 1)
            {
                return;
            }

            var application = this._client.Application.Get();
            var page        = application.ActivePage;
            var target_ids  = targets.ToShapeIDs();

            using (var undoscope = this._client.Application.NewUndoScope("Snap Shape Size"))
            {
                ArrangeHelper.SnapSize(page, target_ids, snapsize, minsize);
            }
        }
Exemple #34
0
        public GridLayout(int cols, int rows, Drawing.Size cellsize, IVisio.Master master)
        {
            this.ColumnDirection = ColumnDirection.LeftToRight;
            this.RowDirection    = RowDirection.BottomToTop;
            this.CellSpacing     = new Drawing.Size(0.5, 0.25);
            this.ColumnCount     = cols;
            this.RowCount        = rows;

            // initialize the sizes for the rows and columns
            this.Rows = new List <Row>(this.RowCount);
            foreach (int row in Enumerable.Range(0, this.RowCount))
            {
                var r = new Row();
                r.Height = cellsize.Height;
                this.Rows.Add(r);
            }

            this.Columns = new List <Column>(this.ColumnCount);
            foreach (int col in Enumerable.Range(0, this.ColumnCount))
            {
                var c = new Column();
                c.Width = cellsize.Width;
                this.Columns.Add(c);
            }

            // Create the nodes
            this._nodes = new Node[this.RowCount, this.ColumnCount];
            foreach (int row in Enumerable.Range(0, this.RowCount))
            {
                foreach (int col in Enumerable.Range(0, this.ColumnCount))
                {
                    var node = new Node();
                    node.Column           = col;
                    node.Row              = row;
                    node.Master           = master;
                    node.Draw             = true;
                    this._nodes[row, col] = node;
                }
            }
        }
        public void SnapSize(IList<IVisio.Shape> target_shapes, double w, double h)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();
            
            var shapes = this.GetTargetShapes2D(target_shapes);
            if (shapes.Count < 1)
            {
                return;
            }


            var shapeids = shapes.Select(s => s.ID).ToList();

            var application = this.Client.Application.Get();
            using (var undoscope = this.Client.Application.NewUndoScope("Snape Shape Sizes"))
            {
                var active_page = application.ActivePage;
                var snapsize = new Drawing.Size(w, h);
                var minsize = new Drawing.Size(w, h);
                ArrangeCommands.SnapSize(active_page, shapeids, snapsize, minsize);
            }
        }
Exemple #36
0
        private Drawing.Size Draw(Graphics g = null)
        {
            g?.Clear(BackColor);

            // get size
            var size = new Drawing.Size();
            var W = Enumerable.Range(0, View.Columns.Count)
                .Select(i => View.Columns[i].Width).ToArray();
            size.Width = W.Sum();

            if (g != null)
            {
                // draw column headers
                var rect = new Rectangle(0, 0, 0, TextRenderer.MeasureText("Wg", View.Font).Height);
                foreach (ColumnHeader column in View.Columns)
                {
                    rect.Width = column.Width;
                    g.FillRectangle(headerBackBrush, rect);
                    g.DrawRectangle(headerBorderPen, rect);
                    g.DrawString(column.Text, View.Font, headerForeBrush, rect, HeaderFormat);
                    rect.X += rect.Width;
                }

                // draw group headers
                foreach (ListViewGroup group in View.Groups)
                {
                    if (group.Items.Count == 0)
                        continue;
                    rect = group.Items[0].Bounds;
                    rect.Y -= rect.Height + 2;
                    rect.Width = TextRenderer.MeasureText(group.Header, View.Font).Width + 3;
                    g.DrawString(group.Header, View.Font, groupForeBrush, rect.X, rect.Y);
                    rect.Y += rect.Height / 2;
                    g.DrawLine(groupBorderPen, rect.Width, rect.Y, size.Width, rect.Y);
                }
            }

            // draw items
            foreach (ListViewItem item in View.Items)
            {
                var rect = item.Bounds;
                for (int i = 0; i < item.SubItems.Count; i++)
                {
                    var sub = item.SubItems[i];
                    rect.Width = W[i];
                    g?.DrawString(sub.Text, sub.Font, headerForeBrush, rect, ItemFormat);
                    rect.X += W[i];
                    size.Height = Math.Max(size.Height, rect.Bottom);
                }
            }

            size.Width++;
            size.Height++;
            return size;
        }
 protected Layout()
 {
     this.AvenueSize = new Drawing.Size(0.375, 0.375);
 }
        public Drawing.Size GetSize()
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var application = this.Client.Application.Get();
            var active_page = application.ActivePage;


            var query = new ShapeSheet.Query.CellQuery();
            var col_height = query.AddCell(ShapeSheet.SRCConstants.PageHeight, "PageHeight");
            var col_width = query.AddCell(ShapeSheet.SRCConstants.PageWidth, "PageWidth");
            var results = query.GetResults<double>(active_page.PageSheet);
            double height = results[col_height];
            double width = results[col_width];
            var s = new Drawing.Size(width, height);
            return s;
        }
        public void SetSize(double? width, double? height)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            if (!width.HasValue && !height.HasValue)
            {
                // nothing to do
                return;
            }

            var old_size = this.GetSize();
            var w = width.GetValueOrDefault(old_size.Width);
            var h = height.GetValueOrDefault(old_size.Height);
            var new_size = new Drawing.Size(w, h);
            this.SetSize(new_size);
        }
        public void FitShapeToText(IList<IVisio.Shape> target_shapes)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var shapes = this.GetTargetShapes2D(target_shapes);
            if (shapes.Count < 1)
            {
                return;
            }

            var application = this.Client.Application.Get();
            var active_page = application.ActivePage;
            var shapeids = shapes.Select(s => s.ID).ToList();

            using (var undoscope = this.Client.Application.NewUndoScope("FitShapeToText"))
            {
                // Calculate the new sizes for each shape
                var new_sizes = new List<Drawing.Size>(shapeids.Count);
                foreach (var shape in shapes)
                {
                    var text_bounding_box = shape.GetBoundingBox(Microsoft.Office.Interop.Visio.VisBoundingBoxArgs.visBBoxUprightText).Size;
                    var wh_bounding_box = shape.GetBoundingBox(Microsoft.Office.Interop.Visio.VisBoundingBoxArgs.visBBoxUprightWH).Size;

                    double max_w = System.Math.Max(text_bounding_box.Width, wh_bounding_box.Width);
                    double max_h = System.Math.Max(text_bounding_box.Height, wh_bounding_box.Height);
                    var max_size = new Drawing.Size(max_w, max_h);
                    new_sizes.Add(max_size);
                }

                var src_width = ShapeSheet.SRCConstants.Width;
                var src_height = ShapeSheet.SRCConstants.Height;

                var update = new ShapeSheet.Update();
                for (int i = 0; i < new_sizes.Count; i++)
                {
                    var shapeid = shapeids[i];
                    var new_size = new_sizes[i];
                    update.SetFormula((short)shapeid, src_width, new_size.Width);
                    update.SetFormula((short)shapeid, src_height, new_size.Height);
                }

                update.Execute(active_page);
            }
        }
        public IVisio.Document New(double w, double h,string template)
        {
            this.Client.Application.AssertApplicationAvailable();

            var doc = this.New(template);
            var pagesize = new Drawing.Size(w, h);
            this.Client.Page.SetSize(pagesize);
            return doc;
        }
        private static void SnapSize(IVisio.Page page, IList<int> shapeids, Drawing.Size snapsize, Drawing.Size minsize)
        {
            var input_xfrms = Shapes.XFormCells.GetCells(page, shapeids);
            var output_xfrms = new List<Shapes.XFormCells>(input_xfrms.Count);

            var grid = new Drawing.SnappingGrid(snapsize);
            foreach (var input_xfrm in input_xfrms)
            {
                var inut_size = new Drawing.Size(input_xfrm.Width.Result, input_xfrm.Height.Result);
                var snapped_size = grid.Snap(inut_size);
                double max_w = System.Math.Max(snapped_size.Width, minsize.Width);
                double max_h = System.Math.Max(snapped_size.Height, minsize.Height);
                var new_size = new Drawing.Size(max_w, max_h);

                var output_xfrm = new Shapes.XFormCells();
                output_xfrm.Width = new_size.Width;
                output_xfrm.Height = new_size.Height;

                output_xfrms.Add(output_xfrm);
            }

            // Now apply them
            ArrangeCommands.update_xfrms(page, shapeids, output_xfrms);
        }
        public static void SnapSize(IVisio.Page page, IList<int> shapeids, Drawing.Size snapsize, Drawing.Size minsize)
        {
            var input_xfrms = Shapes.XFormCells.GetCells(page, shapeids);
            var output_xfrms = new List<Shapes.XFormCells>(input_xfrms.Count);

            var grid = new Drawing.SnappingGrid(snapsize);
            foreach (var input_xfrm in input_xfrms)
            {
                // First snap the size to the grid
                double old_w = input_xfrm.Width.Result;
                double old_h = input_xfrm.Height.Result;
                var input_size = new Drawing.Size(old_w, old_h);
                var snapped_size = grid.Snap(input_size);

                // then account for any minum size requirements
                double new_w = System.Math.Max(snapped_size.Width, minsize.Width);
                double new_h = System.Math.Max(snapped_size.Height, minsize.Height);
                var output_size = new Drawing.Size(new_w, new_h);
                
                // Output the new size for the shape if the size of the shape changed
                bool different_widths = (old_w != new_w);
                bool different_heights = (old_h != new_h);
                if (different_widths || different_heights)
                {
                    var output_xfrm = new Shapes.XFormCells();
                    if (different_widths) 
                    {
                        output_xfrm.Width = output_size.Width;                    
                    }
                    if (different_heights)
                    {
                        output_xfrm.Height = output_size.Height;
                    }
                    output_xfrms.Add(output_xfrm);
                }
            }

            // Now apply the updates to the sizes
            ArrangeHelper.update_xfrms(page, shapeids, output_xfrms);
        }
        private static Drawing.Point GetPinPositionForCorner(Shapes.XFormCells input_xfrm, Drawing.Point new_lower_left, SnapCornerPosition corner)
        {
            var size = new Drawing.Size(input_xfrm.Width.Result, input_xfrm.Height.Result);
            var locpin = new Drawing.Point(input_xfrm.LocPinX.Result, input_xfrm.LocPinY.Result);

            switch (corner)
            {
                case SnapCornerPosition.LowerLeft:
                    {
                        return new_lower_left.Add(locpin.X, locpin.Y);
                    }
                case SnapCornerPosition.UpperRight:
                    {
                        return new_lower_left.Subtract(size.Width, size.Height).Add(locpin.X, locpin.Y);
                    }
                case SnapCornerPosition.LowerRight:
                    {
                        return new_lower_left.Subtract(size.Width, 0).Add(locpin.X, locpin.Y);
                    }
                case SnapCornerPosition.UpperLeft:
                    {
                        return new_lower_left.Subtract(0, size.Height).Add(locpin.X, locpin.Y);
                    }
                default:
                    {
                        throw new System.ArgumentOutOfRangeException(nameof(corner), "Unsupported corner");
                    }
            }
        }