Exemple #1
0
        private void SetControl(ThW.UI.Controls.Control selectedControl, bool refreshProperties)
        {
            this.activeControl               = selectedControl;
            this.comboBox1.SelectedItem      = selectedControl;
            this.propertyGrid.SelectedObject = selectedControl;

            if (null != selectedControl)
            {
                selectedControl.DrawOutline = true;

                foreach (ThW.UI.Controls.Control control in this.activeWindow.WindowControls)
                {
                    if (selectedControl != control)
                    {
                        control.DrawOutline = false;
                    }
                }

                if (selectedControl != this.activeWindow)
                {
                    this.activeWindow.DrawOutline = false;
                }
            }

            this.designControlState = 0;

            if (true == refreshProperties)
            {
                FillControls();
            }
        }
Exemple #2
0
        private void CollectFonts(ThW.UI.Controls.Control control, HashSet <Font> fonts)
        {
            if (null == control)
            {
                return;
            }

            FontStyle style = FontStyle.Regular;

            if (control.FontInfo.Bold)
            {
                style |= FontStyle.Bold;
            }

            if (control.FontInfo.Italic)
            {
                style |= FontStyle.Italic;
            }

            fonts.Add(new Font(control.FontInfo.Name, control.FontInfo.Size, style));

            foreach (var child in control.Controls)
            {
                CollectFonts(child, fonts);
            }
        }
Exemple #3
0
        private void MouseRelease(int x, int y)
        {
            if (null != this.activeWindow)
            {
                ThW.UI.Controls.Control c = this.activeWindow.FindControl(x, y);

                if (null != c)
                {
                    if (false == (c is ThW.UI.Controls.Button))
                    {
//                        c.OnClick(x, y);
                    }

                    while ((c.CreationFlag & CreationFlag.SelectableInDesigner) == 0)
                    {
                        c = c.Parent;

                        if (null == c)
                        {
                            break;
                        }
                    }
                }

                this.activeControl = c;

                this.comboBox1.SelectedItem = c;

                if (null != c)
                {
                    c.DrawOutline = true;

                    foreach (ThW.UI.Controls.Control control in this.activeWindow.WindowControls)
                    {
                        if (c != control)
                        {
                            control.DrawOutline = false;
                        }
                    }

                    if (c != this.activeWindow)
                    {
                        this.activeWindow.DrawOutline = false;
                    }
                }
            }

            this.designControlState = 0;
        }
Exemple #4
0
        private void CreateDesignControl(String controlType, int x, int y)
        {
            ThW.UI.Controls.Control parentControl = FindDesignControl(x, y);

            if ((null != parentControl) && (null != this.activeWindow))
            {
                String controlName = controlType;

                if (false == parentControl.CanContainControl(controlName))
                {
                    return;
                }

                int i = 0;

                while (null != this.activeWindow.FindControl(controlName))
                {
                    controlName = controlType + "_" + i;
                    i++;
                }

                ThW.UI.Controls.Control newControl = this.activeWindow.CreateControl(controlType, CreationFlag.NeedSaving | CreationFlag.NeedLoading | CreationFlag.SelectableInDesigner);

                if (null != newControl)
                {
                    int cx = 0;
                    int cy = this.activeWindow.TopOffset + 0;

                    for (ThW.UI.Controls.Control pp = parentControl; pp != null; pp = pp.Parent)
                    {
                        cx += pp.X;
                        cy += pp.Y;
                    }

                    newControl.Bounds = new Rectangle(x - cx, y - cy, 95, 24);
                    newControl.Name   = controlName;

                    parentControl.AddControl(newControl);

                    SetControl(newControl, true);
                }
            }
        }
Exemple #5
0
        private ThW.UI.Controls.Control FindDesignControl(int x, int y)
        {
            if (null != this.activeWindow)
            {
                ThW.UI.Controls.Control c = this.activeWindow.FindControl(x, y);

                while ((null != c) && ((c.CreationFlag & CreationFlag.SelectableInDesigner) == 0))
                {
                    c = c.Parent;
                }

                if (null == c)
                {
                    c = this.activeWindow;
                }

                return(c);
            }

            return(null);
        }
Exemple #6
0
        private void MousePressDesign(int x, int y)
        {
            ThW.UI.Controls.Control c = FindDesignControl(x, y);

            SetControl(c, true);

            if (null != c)
            {
                int cx = 0;
                int cy = this.activeWindow.TopOffset;

                for (ThW.UI.Controls.Control pp = c.Parent; pp != null; pp = pp.Parent)
                {
                    ThW.UI.Utils.Rectangle r = pp.Bounds;

                    cx += r.X;
                    cy += r.Y;
                }

                if (this.activeWindow == this.activeControl)
                {
                    cy -= this.activeWindow.TopOffset;
                }

                if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.BottomLeft, x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert | ControlState.ControlResizeHoriz | ControlState.ControlResizeLeft;
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.TopLeft, x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert | ControlState.ControlResizeHoriz | ControlState.ControlResizeTop | ControlState.ControlResizeLeft;
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.TopRight, x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert | ControlState.ControlResizeHoriz | ControlState.ControlResizeTop;
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.BottomRight, x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert | ControlState.ControlResizeHoriz;
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.MiddleLeft, x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeHoriz | ControlState.ControlResizeLeft;
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.MiddleRight, x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeHoriz;
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.TopCenter, x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert | ControlState.ControlResizeTop;
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.BottomCenter, x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert;
                }
                else if (true == c.Bounds.Contains(x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlDragging;
                }
            }
        }
Exemple #7
0
        private void MouseMove1(int x, int y)
        {
            UpdateCursor(MousePointers.PointerStandard);

            if (null != this.activeControl)
            {
                int cx = 0;
                int cy = this.activeWindow.TopOffset;
                ThW.UI.Controls.Control c = this.activeControl;

                for (ThW.UI.Controls.Control pp = c.Parent; pp != null; pp = pp.Parent)
                {
                    ThW.UI.Utils.Rectangle r = pp.Bounds;

                    cx += r.X;
                    cy += r.Y;
                }

                if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.BottomLeft, x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerResize1);
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.TopLeft, x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerResize2);
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.TopRight, x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerResize1);
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.BottomRight, x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerResize2);
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.MiddleLeft, x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerHResize);
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.MiddleRight, x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerHResize);
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.TopCenter, x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerVResize);
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.BottomCenter, x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerVResize);
                }
                else if (true == c.Bounds.IsInside(x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerMove);
                }

                if ((this.designControlState & ControlState.ControlDragging) > 0)
                {
                    int dx = x - this.designMousePress.X;
                    int dy = y - this.designMousePress.Y;

                    this.activeControl.X += dx;
                    this.activeControl.Y += dy;

                    this.designMousePress.SetCoords(x, y);
                }
                else if ((this.designControlState & ControlState.ControlResizing) > 0)
                {
                    int dx = x - this.designMousePress.X;
                    int dy = y - this.designMousePress.Y;

                    int nW = this.activeControl.Width + dx;
                    int nH = this.activeControl.Height + dy;
                    int nX = this.activeControl.X;
                    int nY = this.activeControl.Y;

                    this.designMousePress.SetCoords(x, y);

                    if ((this.designControlState & ControlState.ControlResizeHoriz) == 0)
                    {
                        nW -= dx;
                    }

                    if ((this.designControlState & ControlState.ControlResizeVert) == 0)
                    {
                        nH -= dy;
                    }

                    if ((this.designControlState & ControlState.ControlResizeLeft) > 0)
                    {
                        nX = this.activeControl.X + dx;
                        nW = this.activeControl.Width - dx;

                        if (nW < this.activeControl.MinSize.Width)
                        {
                            nX -= (this.activeControl.MinSize.Width - nW);
                            nW  = this.activeControl.MinSize.Width;
                            this.designMousePress.X -= dx;
                        }
                    }

                    if ((this.designControlState & ControlState.ControlResizeTop) > 0)
                    {
                        nY = this.activeControl.Y + dy;
                        nH = this.activeControl.Height - dy;

                        if (nH < this.activeControl.MinSize.Height)
                        {
                            nY -= (this.activeControl.MinSize.Height - nH);
                            nH  = this.activeControl.MinSize.Height;
                            this.designMousePress.Y -= dy;
                        }
                    }

                    if (nW < this.activeControl.MinSize.Width)
                    {
                        nW = this.activeControl.MinSize.Width;
                        this.designMousePress.X -= dx;
                    }

                    if (nH < this.activeControl.MinSize.Height)
                    {
                        nH = this.activeControl.MinSize.Height;
                        this.designMousePress.Y -= dy;
                    }

                    this.activeControl.Bounds = new Rectangle(nX, nY, nW, nH);
                }
            }
        }
Exemple #8
0
 private void SetEditControl(ThW.UI.Controls.Control control)
 {
     this.activeControl = control;
     FillProperties();
 }
Exemple #9
0
 /// <summary>
 /// Child control clicked.
 /// </summary>
 /// <param name="sender">clicked control</param>
 /// <param name="args">arguments</param>
 private void ChildControlClicked(Control sender, EventArgs args)
 {
     OnClick(-1, -1);
 }
Exemple #10
0
 private void UpButtonClicked(Control sender, EventArgs args)
 {
     if (null != this.activeVirtualFolder)
     {
         FillList(this.activeVirtualFolder.Parent);
     }
 }
Exemple #11
0
        /// <summary>
        /// Releases control, as well as clears active control.
        /// </summary>
        /// <param name="control">contro lto remove</param>
        internal override void DestroyControl(Control control)
        {
            if (control == this.activeControl)
            {
                this.activeControl = null;
            }

            base.DestroyControl(control);
        }
Exemple #12
0
        private void MouseRelease(int x, int y)
        {
            if (null != this.activeWindow)
            {
                ThW.UI.Controls.Control c = this.activeWindow.FindControl(x, y);

                if (null != c)
                {
                    if (false == (c is ThW.UI.Controls.Button))
                    {
            //                        c.OnClick(x, y);
                    }

                    while ((c.CreationFlag & CreationFlag.SelectableInDesigner) == 0)
                    {
                        c = c.Parent;

                        if (null == c)
                        {
                            break;
                        }
                    }
                }

                this.activeControl = c;

                this.comboBox1.SelectedItem = c;

                if (null != c)
                {
                    c.DrawOutline = true;

                    foreach (ThW.UI.Controls.Control control in this.activeWindow.WindowControls)
                    {
                        if (c != control)
                        {
                            control.DrawOutline = false;
                        }
                    }

                    if (c != this.activeWindow)
                    {
                        this.activeWindow.DrawOutline = false;
                    }

                }
            }

            this.designControlState = 0;
        }
Exemple #13
0
        private void ColorSelectorValueChanged(Control sender, EventArgs args)
        {
            Color color = this.SelectedColor;

            if (sender == this.redSelector)
            {
                color.R = this.redSelector.Position;
            }
            if (sender == this.greenSelector)
            {
                color.G = this.greenSelector.Position;
            }
            if (sender == this.blueSelector)
            {
                color.B = this.blueSelector.Position;
            }
            if (sender == this.alphaSelector)
            {
                color.A = this.alphaSelector.Position;
            }

            this.colorPanel.BackColor = color;
        }
Exemple #14
0
 public PropertyDescriptorEx(Property property, ThW.UI.Controls.Control control)
     : base(property.Name, new Attribute[] { new CategoryAttribute(property.Group) })
 {
     this.property = property;
     this.control = control;
 }
Exemple #15
0
        private void UpdateStateFromUI(Control sender, EventArgs args)
        {
            this.selectedAnchor = 0;

            if (true == this.top.Checked)
            {
                this.selectedAnchor |= AnchorStyle.AnchorTop;
            }

            if (true == this.bottom.Checked)
            {
                this.selectedAnchor |= AnchorStyle.AnchorBottom;
            }

            if (true == this.left.Checked)
            {
                this.selectedAnchor |= AnchorStyle.AnchorLeft;
            }

            if (true == this.right.Checked)
            {
                this.selectedAnchor |= AnchorStyle.AnchorRight;
            }
        }
Exemple #16
0
        /// <summary>
        /// Sets active control. Displays its' properties.
        /// </summary>
        /// <param name="control">control under edi</param>
        /// <param name="refresh">shoud the properties list be refreshed</param>
        private void SetControl(Control control, bool refresh)
        {
            if (null != this.activeWindow)
            {
                foreach (Control windowControl in this.activeWindow.WindowControls)
                {
                    windowControl.DrawOutline = false;
                }

                this.activeWindow.DrawOutline = false;
            }

            if (control != this.activeControl)
            {
                if (null != control)
                {
                    this.controlProperties.UpdateValue();
                    this.controlProperties.ClearControls();
                    this.controlProperties.SetProperties(control.Properties);
                }
                else
                {
                    this.controlProperties.ClearControls();
                }
            }

            this.activeControl = control;

            if (null != this.activeControl)
            {
                this.activeControl.DrawOutline = true;
            }

            if (true == refresh)
            {
                RefreshData();
            }
        }
Exemple #17
0
        /// <summary>
        /// Control type selection event handler.
        /// </summary>
        /// <param name="controlTypeToolBoxButton">selected control button</param>
        private void SelectControlType(Control controlTypeToolBoxButton)
        {
            if (null != controlTypeToolBoxButton)
            {
                this.controlToCreateType = controlTypeToolBoxButton.Name;
            }
            else
            {
                this.controlToCreateType = "";
            }

            if (null != this.toolBox)
            {
                foreach (Control control in this.toolBox.Controls)
                {
                    control.DrawOutline = (control == controlTypeToolBoxButton);
                }
            }
        }
Exemple #18
0
        /// <summary>
        /// Creates actual control for getting a property value.
        /// </summary>
        protected void CreateInputControl()
        {
            if (null == this.inputControl)
            {
                this.inputControl = CreateControl(this.property.ControlType, CreationFlag.FlagsNone);
                this.inputControl.Border = BorderStyle.None;
                this.inputControl.BackColor = Colors.None;
                this.inputControl.Value = this.property.Value;
                this.inputControl.ValueChanged += (x, y) => { UpdateValue(true); };
                this.inputControl.LostFocus += (x, y) => { UpdateValue(true); };
                this.inputControl.Bounds = new Rectangle(this.Bounds.Width / 2 + 1, 1, this.Bounds.Width / 2-1, this.Bounds.Height-1);

                if (this.inputControl.Type == ComboBox.TypeName)
                {
                    ComboBox comboBox = (ComboBox)(this.inputControl);

                    String value = this.property.ToString();

                    comboBox.BackColor = Colors.White;

                    List<String> acceptableValues = this.property.GetAcceptableValues(this.Window.Desktop.Theme);

                    foreach (String acceptableValue in acceptableValues)
                    {
                        ComboBoxItem item = comboBox.AddItem(acceptableValue, acceptableValue, "", null);

                        if (true == UIUtils.EqualsIgnoringCase(acceptableValue, value))
                        {
                            comboBox.SelectedItem = item;
                        }
                    }
                }

                this.inputControl.Text = this.property.ToString();

                AddControl(this.inputControl);
            }
        }
Exemple #19
0
        private void SetControl(ThW.UI.Controls.Control selectedControl, bool refreshProperties)
        {
            this.activeControl = selectedControl;
            this.comboBox1.SelectedItem = selectedControl;
            this.propertyGrid.SelectedObject = selectedControl;

            if (null != selectedControl)
            {
                selectedControl.DrawOutline = true;

                foreach (ThW.UI.Controls.Control control in this.activeWindow.WindowControls)
                {
                    if (selectedControl != control)
                    {
                        control.DrawOutline = false;
                    }
                }

                if (selectedControl != this.activeWindow)
                {
                    this.activeWindow.DrawOutline = false;
                }
            }

            this.designControlState = 0;

            if (true == refreshProperties)
            {
                FillControls();
            }
        }
Exemple #20
0
        private void VirtualFileSystemClicked(Control sender, EventArgs args)
        {
            if (null == this.VirtualFileSystemRoot)
            {
                if (null != this.Engine.VirtualFileSystem)
                {
                    this.VirtualFileSystemRoot = this.Engine.VirtualFileSystem.RootFile;
                }
            }

            if (null != this.VirtualFileSystemRoot)
            {
                FillList(this.VirtualFileSystemRoot);
            }
        }
Exemple #21
0
 private void SetEditControl(ThW.UI.Controls.Control control)
 {
     this.activeControl = control;
     FillProperties();
 }
Exemple #22
0
 public override void AddControl(Control pControl)
 {
     this.internalPanel.AddControl(pControl);
 }
Exemple #23
0
 public PropertyDescriptorEx(Property property, ThW.UI.Controls.Control control) : base(property.Name, new Attribute[] { new CategoryAttribute(property.Group) })
 {
     this.property = property;
     this.control  = control;
 }
Exemple #24
0
        private void FileItemClicked(Control sender, EventArgs args)
        {
            FileListItem listItem = (FileListItem)sender;

            if (null != listItem)
            {
                IVirtualFile file = listItem.File;

                if (null != file)
                {
                    if (FileTypes.File != file.Type)
                    {
                        FillList(file);

                        this.selectedVirtualFile = null;
                    }
                    else
                    {
                        this.fileNameTextBox.Text = file.Name;
                        this.selectedVirtualFile = file;
                    }
                }
            }
        }