public CollapsePanel(Manager manager, Control parent, string Name, int expandedHeight = 100, bool extended = true)
        {
            this.panel = new GroupPanel(manager);
            panel.Init();
            panel.Height = expandedHeight;
            panel.Width = parent.Width - 20;
            panel.Resizable = true;
            //panel.Text = "  " + Name.Trim();
            Text = Name;
            this.collapseButton = new Button(manager);
            collapseButton.Init();
            collapseButton.Width = 15;
            collapseButton.Height = 18;
            collapseButton.Text = "^";
            collapseButton.Click += collapseButton_Click;
            this.ExpandedHeight = expandedHeight;

            this.panelControls = new Dictionary<string, Control>();
            this.parent = parent;
            parent.Add(panel);
            parent.Add(collapseButton);
            this.IsExtended = extended;

            parent.Refresh();
        }
Exemplo n.º 2
0
        public void Create(RadioMenuItem controller)
        {
            if (controller != null)
            {
                Control = new Gtk.RadioMenuItem((Gtk.RadioMenuItem)controller.ControlObject);
            }
            else
            {
                Control = new Gtk.RadioMenuItem(string.Empty);
                foreach (Gtk.Widget w in Control.Children)
                {
                    Control.Remove(w);
                }
            }

            Control.Sensitive = enabled;
            var hbox = new Gtk.HBox(false, 4);

            hbox.Add(label);
            hbox.Add(accelLabel);
            Control.Add(hbox);
            Control.Activated += Connector.HandleActivated;
            Control.ShowAll();

            label.AccelWidget = Control;
        }
Exemplo n.º 3
0
        protected void InitializeControls(Control parent, int top)
        {
            foreach (Label label in LabelsToShow)
            {
                parent.Add(label);
            }

            for (int i = 0; i < LabelsToShow.Count; i++)
            {
                Label label = LabelsToShow[i];
                label.Left  = 4;
                label.Width = label.Parent.Width - 4;
                if (i == 0)
                {
                    label.Top = top;
                }
                else
                {
                    label.Top = LabelsToShow[i - 1].Top + LabelsToShow[i - 1].Height + 2;
                }
                if (label is RappingLabel)
                {
                    label.Height    = label.Parent.Height - label.Top - 4;
                    label.Alignment = Alignment.TopLeft;
                    label.TextColor = Microsoft.Xna.Framework.Color.LightGray;
                    (label as RappingLabel).WrapText();
                }
            }
        }
        void UpdateContent()
        {
            _currentView = Element.Content;
            var children = _currentView != null?Platform.GetOrCreateRenderer(_currentView).NativeView : null;

            Control.Add(children);
        }
Exemplo n.º 5
0
        protected override void OnElementPropertyChanged(PropertyChangedEventArgs args)
        {
            base.OnElementPropertyChanged(args);

            var visualElement = Element as VisualElement;

            if (visualElement == null)
            {
                return;
            }

            if (args.PropertyName == nameof(visualElement.Width) || args.PropertyName == nameof(visualElement.Height))
            {
                var blurAmount = (double)Element.GetValue(RoutingEffects.ViewBlur.BlurAmountProperty);

                var blur = UIBlurEffect.FromStyle(UIBlurEffectStyle.Light);

                var blurView = new UIVisualEffectView(blur)
                {
                    Alpha = (nfloat)blurAmount,
                    Frame = new RectangleF(0, 0, (float)((VisualElement)Element).Width, (float)((VisualElement)Element).Height)
                };

                Control.Add(blurView);
            }
        }
Exemplo n.º 6
0
        public void Create(RadioMenuItem controller)
        {
            if (controller != null)
            {
                Control         = new Gtk.RadioMenuItem((Gtk.RadioMenuItem)controller.ControlObject);
                this.controller = (RadioMenuItemHandler)controller.Handler;
            }
            else
            {
                this.controller = this;
                Control         = new Gtk.RadioMenuItem(string.Empty);
                foreach (Gtk.Widget w in Control.Children)
                {
                    Control.Remove(w);
                }
            }

            var hbox = new Gtk.HBox(false, 4);

            label              = new Gtk.AccelLabel(string.Empty);
            label.Xalign       = 0;
            label.UseUnderline = true;
            label.AccelWidget  = Control;
            hbox.Add(label);
            accelLabel         = new Gtk.Label();
            accelLabel.Xalign  = 1;
            accelLabel.Visible = false;
            hbox.Add(accelLabel);
            Control.Add(hbox);
        }
Exemplo n.º 7
0
        protected override void OnElementPropertyChanged(System.ComponentModel.PropertyChangedEventArgs args)
        {
            base.OnElementPropertyChanged(args);

            if (args.PropertyName == "Text")
            {
                if (Element is Entry e)
                {
                    if (e.Text.Length > 8)
                    {
                        Control.BackgroundColor = UIColor.FromRGB(255, 0, 0);

                        if (!Control.Subviews.OfType <UIVisualEffectView>().Any())
                        {
                            var blur             = UIBlurEffect.FromStyle(UIBlurEffectStyle.Light);
                            var visualEffectView = new UIVisualEffectView(blur);
                            visualEffectView.Frame = Control.Bounds;
                            visualEffectView.Alpha = 0.7f;
                            Control.Add(visualEffectView);
                        }
                    }
                    else
                    {
                        Control.BackgroundColor = UIColor.FromRGB(255, 255, 255);
                        foreach (var s in Control.Subviews.OfType <UIVisualEffectView>())
                        {
                            s.RemoveFromSuperview();
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
    public Control GetControl()
    {
        var control = new Control();

        // this assumes Control is also a composite type
        _list.ForEach(displayable => control.Add(displayable.GetControl()));
        return(control);
    }
Exemplo n.º 9
0
        public override int AddInformation(Manager manager, Player player, Control control, int yPos)
        {
            var currentHouse = player.House;
            const int spacing = 20;
            int xPos = spacing;
            if (currentHouse == null) {
                var noHouseLabel = new Label(manager) { Text = "You have no house to sell!", Width = 400, Left = xPos, Top = yPos, Name = IgnoreString };
                noHouseLabel.Init();
                control.Add(noHouseLabel);
            } else {
                var houseGraphic = manager.Game.Content.Load<Texture2D>(currentHouse.HouseGraphic);
                yPos += 20;
                // Put the house graphic into an image box
                var imageBox = new ImageBox(manager) {
                    Left = 16,
                    Top = yPos,
                    Image = houseGraphic,
                    Color = Color.White,
                    Width = houseGraphic.Width,
                    Height = houseGraphic.Height,
                    Name = IgnoreString,
                    Parent = control
                };
                imageBox.Init();

                var descriptionText = new Label(manager) {
                    Text =
                        String.Format(
                            "Name : {0}\n\n" +
                            "Average Value: ${1:N0}\n\n" +
                            "Current Value: ${2:N0}\n\n" +
                            "Bought for : ${3:N0}\n\n" +
                            "Total profit :: ${4:N0}",
                            currentHouse.Name, currentHouse.InitialValue, currentHouse.Value, currentHouse.PlayerBuyingValue, currentHouse.PlayerBuyingValue - currentHouse.Value),
                    Top = yPos,
                    Left = imageBox.Width + 60,
                    Height = 130,
                    Width = 200,
                    Parent = control,
                    Name = IgnoreString
                };
                yPos += imageBox.Height + 20;
                var sellHouseButton = new Button(manager) {
                    Text =
                        "Sell House",
                    Width = 400, Left = xPos, Top = yPos,
                    Name = IgnoreString
                };
                sellHouseButton.Click += (sender, args) => {
                    _houseCallback(player, currentHouse);
                    PopulateTab(manager, player, control);
                };
                sellHouseButton.Init();
                control.Add(sellHouseButton);
            }
            return yPos;
        }
Exemplo n.º 10
0
 void AddEntry(string type, object data, Action <DataObjectData, Gtk.SelectionData> getData)
 {
     Control.Add(new DataObjectData
     {
         Target      = new Gtk.TargetEntry(type, 0, (uint)Control.Count),
         Data        = data,
         GetDataFunc = getData
     });
 }
Exemplo n.º 11
0
        protected override void Initialize()
        {
            base.Initialize();
            var vbox = new Gtk.VBox();

            vbox.PackStart(WindowActionControl, false, true, 0);
            vbox.PackStart(WindowContentControl, true, true, 0);
            Control.Add(vbox);
        }
Exemplo n.º 12
0
        protected override void SetContainerContent(Gtk.Widget content)
        {
            Control.Add(content);

            /*if (clientSize != null) {
             *      var label = Control.LabelWidget;
             *      Control.SetSizeRequest(clientSize.Value.Width + 10, clientSize.Value.Height + label.Allocation.Height + 10);
             *      clientSize = null;
             * }*/
        }
Exemplo n.º 13
0
 public void InsertTab(int index, TabPage page)
 {
     if (index == -1)
     {
         Control.Add(((TabPageHandler)page.Handler).TabViewItem);
     }
     else
     {
         Control.Insert(((TabPageHandler)page.Handler).TabViewItem, index);
     }
 }
        void UpdateContent()
        {
            if (Element is ContentPage page)
            {
                _currentView = page.Content;
                var content = _currentView != null?Platform.GetOrCreateRenderer(_currentView).NativeView : null;

                Control.Add(content);
                FormsWindow.Current.Add(content);
            }
        }
        void HandleChildAdded(object sender, ElementEventArgs e)
        {
            if (!(e.Element is VisualElement view))
            {
                return;
            }

            IVisualElementRenderer renderer;

            Platform.SetRenderer(view, renderer = Platform.CreateRenderer(view));
            Control.Add(renderer.GetNativeElement());
        }
Exemplo n.º 16
0
 protected override void ApplyModelCore()
 {
     if (Model.Any(label => label.NodeEnabled))
     {
         Control.Clear();
         foreach (var modelAppoitmentStatus in Model)
         {
             Control.Add(modelAppoitmentStatus.GetValue <Color>("Color"),
                         modelAppoitmentStatus.GetValue <string>("DisplayName"),
                         modelAppoitmentStatus.GetValue <string>("MenuCaption"));
         }
     }
 }
Exemplo n.º 17
0
 protected override void ApplyModelCore()
 {
     if (Model.Any(label => label.NodeEnabled))
     {
         Control.Clear();
         foreach (var modelAppoitmentStatus in Model)
         {
             var appointmentLabel = Control.CreateNewStatus(null);
             Control.Add(appointmentLabel);
             ApplyModel(modelAppoitmentStatus, appointmentLabel, ApplyValues);
         }
     }
 }
Exemplo n.º 18
0
 void AddPins(IEnumerable pins)
 {
     foreach (Pin pin in pins)
     {
         var coordinates = new Geocoordinates(pin.Position.Latitude, pin.Position.Longitude);
         var nativePin   = new TPin(coordinates);
         nativePin.Clicked += (s, e) =>
         {
             pin.SendTap();
         };
         Control.Add(nativePin);
         _pins.Add(pin, nativePin);
     }
 }
Exemplo n.º 19
0
        protected override void OnElementChanged(ElementChangedEventArgs <View> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                Control.Add(pickerControl);
            }

            if (e.NewElement != null)
            {
                (e.NewElement as StackLayout).Children.Add(pickerControl);
            }
        }
Exemplo n.º 20
0
 public void Create(RadioButton controller)
 {
     if (controller != null)
     {
         Control = new Gtk.RadioButton((Gtk.RadioButton)controller.ControlObject);
     }
     else
     {
         Control = new Gtk.RadioButton((Gtk.RadioButton)null);
     }
     label = new Gtk.AccelLabel("");
     Control.Add(label);             //control.AddMnemonicLabel(label);
     Control.Toggled += control_Toggled;
 }
Exemplo n.º 21
0
        protected override void Initialize()
        {
            Tree = new Gtk.TreeView();
            UpdateModel();
            Tree.HeadersVisible = true;
            Control.Add(Tree);

            Tree.Events           |= Gdk.EventMask.ButtonPressMask;
            Tree.ButtonPressEvent += Connector.HandleButtonPress;

            columns = new ColumnCollection {
                Handler = this
            };
            columns.Register(Widget.Columns);
            base.Initialize();
        }
Exemplo n.º 22
0
 void AddPins(IEnumerable pins)
 {
     foreach (Pin pin in pins)
     {
         pin.PropertyChanged += PinOnPropertyChanged;
         var coordinates = new Geocoordinates(pin.Position.Latitude, pin.Position.Longitude);
         var nativePin   = new TPin(coordinates);
         pin.MarkerId       = nativePin;
         nativePin.Clicked += (s, e) =>
         {
             pin.SendMarkerClick();
         };
         Control.Add(nativePin);
         _pins.Add(pin);
     }
 }
Exemplo n.º 23
0
        public override void SetLayout(Layout inner)
        {
            if (Control.Child != null)
            {
                Control.Remove(Control.Child);
            }
            IGtkLayout gtklayout = (IGtkLayout)inner.Handler;
            var        widget    = (Gtk.Widget)gtklayout.ContainerObject;

            Control.Add(widget);

            /*if (clientSize != null) {
             *      var label = Control.LabelWidget;
             *      Control.SetSizeRequest(clientSize.Value.Width + 10, clientSize.Value.Height + label.Allocation.Height + 10);
             *      clientSize = null;
             * }*/
        }
Exemplo n.º 24
0
        void ApplyIsShowingUser(Geocoordinates coordinates)
        {
            if (_marker == null)
            {
                _marker           = new Sticker(coordinates);
                _marker.IsVisible = false;
                Control.Add(_marker);
            }
            _marker.Coordinates = coordinates;

            if (!_marker.IsVisible)
            {
                _marker.IsVisible = true;
                Control.Center    = coordinates;
                Control.ZoomLevel = 13;
            }
        }
Exemplo n.º 25
0
 public void Create(RadioButton controller)
 {
     if (controller != null)
     {
         Control = new Gtk.RadioButton(RadioButtonHandler.GetControl(controller));
     }
     else
     {
         Control = new Gtk.RadioButton((Gtk.RadioButton)null);
         // make gtk work like others in that no radio button is initially selected
         var inactive = new Gtk.RadioButton(Control);
         inactive.Active = true;
     }
     label = new Gtk.AccelLabel("");
     Control.Add(label);             //control.AddMnemonicLabel(label);
     Control.Toggled += Connector.HandleCheckedChanged;
 }
Exemplo n.º 26
0
        void AddPins(IEnumerable pins)
        {
            foreach (Pin pin in pins)
            {
                pin.PropertyChanged += PinOnPropertyChanged;
                var coordinates = new Geocoordinates(pin.Position.Latitude, pin.Position.Longitude);
                var nativePin   = new TPin(coordinates);
                pin.MarkerId       = nativePin;
                nativePin.Clicked += (s, e) =>
                {
#pragma warning disable CS0618
                    pin.SendTap();
#pragma warning restore CS0618
                };
                Control.Add(nativePin);
                _pins.Add(pin);
            }
        }
        private void LoadContent()
        {
            var currentView = Element.Content;

            IVisualElementRenderer renderer = null;

            if (currentView != null)
            {
                renderer = currentView.GetOrCreateRenderer();
            }

            if (renderer != null)
            {
                var content = renderer.GetNativeElement();

                Control.Add(content);
            }
        }
Exemplo n.º 28
0
        public RoomPanel(Sidebar sidebar, Control parent, Room room, bool interactive, int Top = 0, int Padding = 5)
        {
            this.Padding = Padding;
            panel = new Panel(sidebar.manager);
            panel.Init();
            panel.Top = Top;
            panel.Left = Padding;
            panel.Width = room.worldWidth;
            panel.Height = room.worldHeight;

            //roomPanel.Left = (parent.Width - roomPanel.Width)/2;

            int col = 30;

            panel.Color = new Color(col, col, col);
            panel.BevelBorder = BevelBorder.All;
            panel.BevelStyle = BevelStyle.Flat;
            panel.BevelColor = Color.Black;

            parent.Add(panel);
            panel.ClientArea.Draw += (s, e) =>
            {

                e.Renderer.Draw(room.roomRenderTarget, e.Rectangle, Color.White);

            };

            refreshAction = refresh;

            parent.VisibleChanged += (s, e) => {
                if (parent.Visible)
                    OrbIt.OnUpdate += refreshAction;
                else
                    OrbIt.OnUpdate -= refreshAction;
            };

            panel.Click += (s, e) =>
            {
                Point innerpos = (e as MouseEventArgs).Position;
                //room.spawnNode(innerpos.X, innerpos.Y);
                Utils.notImplementedException();
            };
        }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            while (true)
            {
                Control data = new Control();

                System.Console.WriteLine(">> FileSystem TEST");
                System.Console.WriteLine();
                System.Console.WriteLine("1. Open / Create File");
                System.Console.WriteLine("2. Add Element");
                System.Console.WriteLine("3. Update Element");
                System.Console.WriteLine("4. Remove Element");
                System.Console.WriteLine("5. Search Element");
                System.Console.WriteLine("6. Print List");
                System.Console.WriteLine();
                System.Console.WriteLine("0. Close / Quit Program");
                System.Console.WriteLine();
                System.Console.Write("Select Number : ");

                // select menu
                Select? sel = null;
                try
                {
                    sel = (Select)int.Parse(System.Console.ReadLine());
                }
                catch (Exception e) { }
                System.Console.WriteLine();
                switch (sel)
                {
                    case Select.Open: data.Open(); break;
                    case Select.Add: data.Add(); break;
                    case Select.Update: data.Update();  break;
                    case Select.Remove: data.Remove(); break;
                    case Select.Search: data.Search(); break;
                    case Select.List: data.List(); break;
                    case Select.Close: return;
                    default:
                        System.Console.WriteLine(">> Plz input Number (0~6)\n");break;
                }
            }
        }
Exemplo n.º 30
0
        public void Add(BaseResource resource)
        {
            switch (resource.Category)
            {
            case Category.Input:
                Input.Add(resource);
                break;

            case Category.Output:
                Output.Add(resource);
                break;

            case Category.Control:
                Control.Add(resource);
                break;

            case Category.Mechanism:
                Mechanism.Add(resource);
                break;

            default: throw new Exception("Неизвестный тип ресурса!");
            }
        }
Exemplo n.º 31
0
        public void Init(Control parent, Manager manager)
        {
            switch (Type)
            {
                case "Container":
                    Container container = new Container(manager);
                    container.Init();

                    SetProperties(container, parent, manager);

                    container.AutoScroll = true;
                    break;
                case "ImageBox":
                    ImageBox box = new ImageBox(manager);
                    box.Init();

                    SetProperties(box, parent, manager);

                    box.SizeMode = ImageMode;

                    if (!string.IsNullOrEmpty(ImageAsset))
                        box.Image = manager.Content.Load<Texture2D>(ImageAsset);
                    else if (AtlasAsset != null)
                    {
                        if (AtlasAsset.Atlas == "IconProvider")
                            box.Image = IconProvider.GetByName(AtlasAsset.Name);
                        else
                            box.Image = Provider.GetAtlas(AtlasAsset.Atlas).GetTexture(AtlasAsset.Name);
                    }

                    if (!string.IsNullOrEmpty(Draw))
                        box.Draw += delegate(object sender, DrawEventArgs e)
                        {
                            if (EventFieldDraw == null)
                            {
                                Type classType = parent.GetType();
                                EventFieldDraw = classType.GetMethod(Draw);
                            }

                            if (EventFieldDraw == null)
                                throw new Exception("Could not find: " + Draw + " method");

                            EventFieldDraw.Invoke(parent, new object[] { sender, e });
                        };
                    break;
                case "Label":
                    Label label = new Label(manager);
                    label.Init();

                    SetProperties(label, parent, manager);

                    label.Text = Text.StartsWith("TXT_KEY_") ? Provider.Instance.Translate(Text) : Text;

                    break;
                case "GameMapBox":
                    GameMapBox mapBox = new GameMapBox(manager);
                    mapBox.Init();

                    SetProperties(mapBox, parent, manager);

                    break;
                case "SideBar":
                    SideBar sideBar = new SideBar(manager);
                    sideBar.Init();

                    SetProperties(sideBar, parent, manager);

                    if (!string.IsNullOrEmpty(Draw))
                        sideBar.Draw += delegate(object sender, DrawEventArgs e)
                        {
                            if (EventFieldDraw == null)
                            {
                                Type classType = parent.GetType();
                                EventFieldDraw = classType.GetMethod(Draw);
                            }

                            if (EventFieldDraw == null)
                                throw new Exception("Could not find: " + Draw + " method");

                            EventFieldDraw.Invoke(parent, new object[] { sender, e });
                        };

                    break;
                case "ContextMenu":
                    ContextMenu contextMenu = new ContextMenu(manager);
                    contextMenu.Init();

                    contextMenu.Name = Name;
                    contextMenu.Tag = this;
                    contextMenu.Passive = Passive;
                    contextMenu.Enabled = Enabled;

                    foreach (MenuItemEntry entry in Items)
                    {
                        MenuItem menuItem = new MenuItem(entry.Title);
                        menuItem.Enabled = entry.Enabled;

                        contextMenu.Items.Add(menuItem);
                    }

                    if (!string.IsNullOrEmpty(Parent))
                        contextMenu.Parent = parent.GetControl(Parent);
                    else
                        parent.Add(contextMenu);

                    break;

                case "ImageListBox":
                    ImageListBox listBox = new ImageListBox(manager);
                    listBox.Init();

                    SetProperties(listBox, parent, manager);

                    listBox.HideSelection = HideSelection;

                    if (!string.IsNullOrEmpty(ContextMenu))
                        listBox.ContextMenu = parent.GetControl(ContextMenu) as ContextMenu;

                    break;

                case "TechInfoButton":
                    TechInfoButton techInfo = new TechInfoButton(manager);
                    techInfo.Init();

                    SetProperties(techInfo, parent, manager);

                    if (!string.IsNullOrEmpty(TechName))
                        techInfo.Tech = Provider.GetTech(TechName);

                    break;
                case "PolicyButton":
                    PolicyButton policyButton = new PolicyButton(manager);
                    policyButton.Init();

                    SetProperties(policyButton, parent, manager);

                    if (!string.IsNullOrEmpty(PolicyName))
                        policyButton.Policy = Provider.GetPolicy(PolicyName);

                    break;
                case "PolicyTypeBox":
                    PolicyTypeBox policyTypeBox = new PolicyTypeBox(manager);
                    policyTypeBox.Init();

                    SetProperties(policyTypeBox, parent, manager);

                    if (!string.IsNullOrEmpty(PolicyTypeName))
                        policyTypeBox.PolicyType = Provider.GetPolicyType(PolicyTypeName);

                    if (!string.IsNullOrEmpty(ImageAsset))
                        policyTypeBox.Image = manager.Content.Load<Texture2D>(ImageAsset);
                    else if (AtlasAsset != null)
                    {
                        if (AtlasAsset.Atlas == "IconProvider")
                            policyTypeBox.Image = IconProvider.GetByName(AtlasAsset.Name);
                        else
                            policyTypeBox.Image = Provider.GetAtlas(AtlasAsset.Atlas).GetTexture(AtlasAsset.Name);
                    }

                    break;
                case "ImageButton":
                    ImageButton button = new ImageButton(manager);
                    button.Init();

                    ApplyStyle(button, manager);
                    SetProperties(button, parent, manager);
                    SetAnimation(button, manager);

                    button.Text = Text;
                    break;
                case "ProgressBar":
                    ProgressBar progress = new ProgressBar(manager);
                    progress.Init();

                    SetProperties(progress, parent, manager);
                    break;
                case "CheckBox":
                    CheckBox check = new CheckBox(manager);
                    check.Init();

                    SetProperties(check, parent, manager);

                    check.Text = Text;
                    break;
                case "Graph":
                    Graph graph = new Graph(manager);
                    graph.Init();

                    SetProperties(graph, parent, manager);

                    break;
                case "RankingRow":
                    RankingRow rank = new RankingRow(manager);
                    rank.Init();

                    SetProperties(rank, parent, manager);
                    break;
                case "Include":
                    List<ControlItem> children = manager.Content.Load<List<ControlItem>>(Import);

                    foreach (ControlItem item in children)
                        item.Init(parent, manager);
                    break;
                default:
                    throw new Exception("No handling for " + Type);
            }
        }
Exemplo n.º 32
0
    // This function adds a ComboBox to the passed control collection, along
    //   with an associated Label control to display the survey question.
    private Point Survey_AddComboBox(XmlNode inNode ,Control.ControlCollection inControls,
			Point location ,string tag)
    {
        // Create a new control.
        ComboBox myCombo = new ComboBox();
        // set {up some properties for the control
        myCombo.Text = "";
        myCombo.Name = inNode.Attributes["name"].Value;
        myCombo.Tag = tag;
        myCombo.Width = CONTROL_WIDTH;
        // Create a temporary XML Node to use when retrieving information
        //   about the response nodes in the passed node.
        // get {the response nodes.
        foreach(XmlNode myNode in inNode.SelectNodes("responses/response"))
                                  {
            // Add the InnerText of the response nodes as the values for
            //   the drop down options.
            myCombo.Items.Add(myNode.InnerText);
            // if a default has been specified, use it as the current text.
            if (myNode.Attributes["default"] != null) {
                if (myNode.Attributes["default"].Value == "true")
                    {
                    myCombo.Text = myNode.InnerText;
                }
            }
        }

        // Create a Label and add it to the collection

        Label myLabel = new Label();
        // set {up some properties for the control
        myLabel.Name = myCombo.Name + "Label";
        myLabel.Text = inNode.SelectSingleNode("text").InnerText;
        myLabel.Width = CONTROL_WIDTH;
        // Add the control to the Controls collection, and reset
        //   the location to the location for the next control.
        myLabel.Location = location;
        inControls.Add(myLabel);
        location.Y += myLabel.Height;
        // Add the control to the Controls collection, and reset
        //   the location to the location for the next control.
        myCombo.Location = location;
        inControls.Add(myCombo);
        location.Y += myCombo.Height + 10;
        // Send back the location for the next control to be added.
        return location;
    }
Exemplo n.º 33
0
 // This function adds a ListBox to the passed control collection, along
 //   with an associated Label control to display the survey question.
 private Point Survey_AddListBox(XmlNode inNode , Control.ControlCollection inControls ,
     Point location ,string tag, bool isMultiSelect)
 {
     // Create a new control.
     ListBox myList =  new ListBox();
     // set {up some properties for the control
     myList.Text = "";
     myList.Name = inNode.Attributes["name"].Value;
     myList.Tag = tag;
     myList.Width = CONTROL_WIDTH;
     // Since this function can be used with either multi or single select
     //   list boxes, set the proper SelectionMode based on the passed
     //   isMultiSelect bool variable.
     if (isMultiSelect)
     {
         myList.SelectionMode = SelectionMode.MultiSimple;
     }
     else
     {
         myList.SelectionMode = SelectionMode.One;
     }
     // Create a temporary XML Node to use when retrieving information
     //   about the response nodes in the passed node.
     // Add the InnerText of the response nodes as the values for
     //   the list box options.
     foreach(XmlNode myNode in inNode.SelectNodes("responses/response"))
         {
         myList.Items.Add(myNode.InnerText);
         // if a default has been specified, use it as the current text.
         if (myNode.Attributes["default"] != null)
             {
             if (myNode.Attributes["default"].Value == "true") {
                 myList.Text = myNode.InnerText;
             }
         }
     }
     // Create a Label and add it to the collection
     Label myLabel = new Label();
     // set {up some properties for the control
     myLabel.Name = myList.Name + "Label";
     myLabel.Text = inNode.SelectSingleNode("text").InnerText;
     myLabel.Width = CONTROL_WIDTH;
     // Add the control to the Controls collection, and reset
     //   the location to the location for the next control.
     myLabel.Location = location;
     inControls.Add(myLabel);
     location.Y += myLabel.Height;
     // Add the control to the Controls collection, and reset
     //   the location to the location for the next control.
     myList.Location = location;
     inControls.Add(myList);
     location.Y += myList.Height + 10;
     // Send back the location for the next control
     return location;
 }
Exemplo n.º 34
0
 // This function adds a GroupBox to the passed control collection, along
 //   with all the appropriate radio buttons, one for each available response.
 //   It also adds an associated Label control to display the survey question.
 private Point Survey_AddRadioButtons(XmlNode inNode, Control.ControlCollection inControls ,
     Point location ,string tag)
 {
     // Must create a GroupBox to contain the radio buttons
     //   otherwise they are not logically distinct from the other
     //   radio buttons on the form.
     GroupBox myGroupBox = new GroupBox();
     // set {up some properties for the control.
     myGroupBox.Text = "";
     myGroupBox.Name = inNode.Attributes["name"].Value;
     myGroupBox.Tag = tag;
     myGroupBox.Width = CONTROL_WIDTH + 20;
     // Create some useful variables to use in the following block of code.
     Point myRadioPoint = new Point(5, 10);
     // Loop through each response, and add it as a new radio button.
     foreach(XmlNode myNode in inNode.SelectNodes("responses/response"))
     {
         // Create the radio button.
         RadioButton myRadio = new RadioButton();
         // Add the appropriate properties.
         myRadio.Text = myNode.InnerText;
         myRadio.Location = myRadioPoint;
         myRadioPoint.Y += myRadio.Height;
         // set {the default value as the selected radio button, but
         //   only if the default attribute exists and is set to true.
         if (myNode.Attributes["default"] != null)
             {
             if (myNode.Attributes["default"].Value == "true")
             {
                 myRadio.Checked = true;
             }
         }
         // Add the control to the group box.
         myGroupBox.Controls.Add(myRadio);
     }
     // Reset the height for the textbox, based on the
     //   contained Radio Buttons.
     myGroupBox.Height = myRadioPoint.Y + 5;
     // Create a Label and add it to the collection.
     Label myLabel = new Label();
     // Fix the label properties.
     myLabel.Name = myGroupBox.Name + "Label";
     myLabel.Text = inNode.SelectSingleNode("text").InnerText;
     myLabel.Width = CONTROL_WIDTH;
     // Add the control to the Controls collection, and reset
     //   the location to the location for the next control.
     myLabel.Location = location;
     inControls.Add(myLabel);
     location.Y += myLabel.Height - 5;
     // Add the control to the Controls collection, and reset
     //   the location to the location for the next control.
     myGroupBox.Location = location;
     inControls.Add(myGroupBox);
     location.Y += myGroupBox.Height + 10;
     // Send back the location for the next control
     return location;
 }
Exemplo n.º 35
0
    // This function adds a TextBox to the passed control collection, along
    //   with an associated Label control to display the survey question.
    private Point Survey_AddTextBox(XmlNode inNode , Control.ControlCollection inControls,
        Point location ,string tag)
    {
        // Create a new control.
        TextBox myText = new TextBox();
        // Fill in some of the appropriate properties
        if (inNode.SelectSingleNode("defaultResponse") != null)
            {
            myText.Text = inNode.SelectSingleNode("defaultResponse").InnerText;
        }
        if (inNode.Attributes["name"] != null) {
            myText.Name = inNode.Attributes["name"].Value;
        }
        myText.Tag = tag;
        myText.Width = CONTROL_WIDTH;
        // set {the MaxLength property based off of the XML node information.
        if (inNode.SelectSingleNode("maxCharacters") != null) {
            myText.MaxLength = int.Parse(inNode.SelectSingleNode("maxCharacters").InnerText);
        }
        // Calculate the number of lines that should be allowed for
        if (myText.MaxLength > 0)
            {
            int numLines  = (myText.MaxLength / CHARS_PER_LINE ) + 1;
            // Calculate how large the textbox should be, and whether
            //   scrollbars are necessary.
            if (numLines == 1)
            {
                myText.Multiline = false;
            }
            else
            {
                if (numLines >= 4)
                {
                    myText.Multiline = true;
                    myText.Height = 4 * HEIGHT_PER_LINE;
                    myText.ScrollBars = ScrollBars.Vertical;
                }
                else
                {
                    myText.Multiline = true;
                    myText.Height = numLines * HEIGHT_PER_LINE;
                    myText.ScrollBars = ScrollBars.None;
                }
            }
        }

        // Create a Label and add it to the collection
        Label myLabel = new Label();
        myLabel.Name = myText.Name + "Label";
        if (inNode.SelectSingleNode("text") != null) {
            myLabel.Text = inNode.SelectSingleNode("text").InnerText;
        }
        myLabel.Width = CONTROL_WIDTH;
        // Add the control to the Controls collection, and reset
        //   the location to the location for the next control.
        myLabel.Location = location;
        inControls.Add(myLabel);
        location.Y += myLabel.Height;
        // Add the control to the Controls collection, and reset
        //   the location to the location for the next control.
        myText.Location = location;
        inControls.Add(myText);
        location.Y += myText.Height + 10;
        // Send back the location for the next control.
        return location;
    }
Exemplo n.º 36
0
        private void OfferToSellHouse(GameInfo gameInfo, IGameState waitState)
        {
            var currentHouse = gameInfo.CurrentPlayer.House;
            var houseGraphic = gameInfo.Content.Load<Texture2D>(currentHouse.HouseGraphic);
            var manager = gameInfo.Manager;

            var container = new Control(manager) { Left = 16, Top = 16, Color = Color.Transparent };
            var firstLine = new Label(manager) { Text = "You have been offered to buy a new house!  \nYou must sell your current house to be able to buy this one. \n\n     Current House:", Width = 400, Height = 60};
            container.Add(firstLine);
            // Put the house graphic into an image box
            var imageBox = new ImageBox(manager)
            {
                Left = 16,
                Top = 60,
                Image = houseGraphic,
                Color = Color.White,
                Width = houseGraphic.Width,
                Height = houseGraphic.Height
            };
            imageBox.Init();
            container.Add(imageBox);

            var descriptionText = new Label(manager)
            {
                Text =
                    String.Format(
                        "Name : {0}\n\n" +
                        "Average Value: ${1:N0}" +
                        "\n\nCurrent Value: ${2:N0}\n\n",
                        currentHouse.Name, currentHouse.InitialValue, currentHouse.Value),
                Top = imageBox.Height / 2,
                Left = imageBox.Width + 60,
                Height = 100,
                Width = 200
            };
            container.Add(descriptionText);

            var newHouse = new Label(gameInfo.Manager)
                               {Text = "     New offered house", Width = 150, Parent = container, Top = 200, Left = 16};
            newHouse.Init();

            var imageBox2 = new ImageBox(manager)
            {
                Left = 16,
                Top = 230,
                Image = gameInfo.Content.Load<Texture2D>(House.HouseGraphic),
                Color = Color.White,
                Width = houseGraphic.Width,
                Height = houseGraphic.Height
            };
            imageBox.Init();
            container.Add(imageBox2);

            var descriptionText2 = new Label(manager)
            {
                Text =
                    String.Format(
                        "Name : {0}\n\n" +
                        "Average Value: ${1:N0}" +
                        "\n\nCurrent Value: ${2:N0}\n\n",
                        House.Name, House.InitialValue, House.Value),
                Top = imageBox.Height*4 / 2,
                Left = imageBox2.Width + 60,
                Height = 100,
                Width = 200
            };
            container.Add(descriptionText2);

            var offerHouseLine = new Label(manager) { Text = "Would you like to sell your current house?", Width = 400, Top = imageBox.Height*2 + 140 };
            container.Add(offerHouseLine);

            container.Width = descriptionText.Left + descriptionText.Width + 16;
            container.Height = offerHouseLine.Top + offerHouseLine.Height;

            //"Would you like to buy this house? \n" + House.Name, "\nDo you want to buy a house""
            var confirmWindow = new ConfirmWindow(manager, String.Empty, title: "Do you want to sell your house?", control: container);
            confirmWindow.AffirmButton.Click += (sender, args) => SellCurrentHouse(confirmWindow, gameInfo, waitState);
            confirmWindow.DenyButton.Click += (sender, args) => CloseWindow(confirmWindow, gameInfo, waitState);
        }
Exemplo n.º 37
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName.Equals("VisibleRegion") && viewReady && !isDrawn)
            {
                Control.RemoveAll();

                var scale        = ElmSharp.Elementary.GetScale();
                int windowWidth  = (int)Math.Round(OverlayWidth * scale);
                int windowHeight = (int)Math.Round(OverlayHeight * scale);

                foreach (var pin in customPins)
                {
                    var coordinates = new Geocoordinates(pin.Position.Latitude, pin.Position.Longitude);

                    Control.Add(new TPin(coordinates, PinPath));

                    int width  = windowWidth;
                    int height = windowHeight;

                    var window = new ElmSharp.Box(Control);
                    window.Show();

                    {
                        var overlay = new ElmSharp.Box(window)
                        {
                            BackgroundColor = XamarinLogoColor,
                        };
                        overlay.SetAlignment(-1.0, -1.0);                     // fill
                        overlay.SetWeight(1.0, 0.0);                          // expand on X axis
                        overlay.Show();
                        window.PackEnd(overlay);

                        if (pin.Id == XamarinId)
                        {
                            var xamarin = new ElmSharp.Image(overlay);
                            xamarin.Load(XamarinPath);
                            xamarin.SetAlignment(-1.0, -1.0);                              // fill
                            var size = xamarin.ObjectSize;
                            xamarin.MinimumWidth  = size.Width;
                            xamarin.MinimumHeight = size.Height;
                            xamarin.Show();
                            overlay.PackEnd(xamarin);

                            height += size.Height;
                        }

                        {
                            var infoBox = new ElmSharp.Box(overlay)
                            {
                                IsHorizontal = true,
                            };
                            infoBox.SetAlignment(-1.0, -1.0);                         // fill
                            infoBox.SetWeight(1.0, 0.0);                              // expand on X axis
                            infoBox.Show();
                            overlay.PackEnd(infoBox);

                            {
                                var monkey = new ElmSharp.Image(infoBox);
                                monkey.Load(MonkeyPath);
                                monkey.SetAlignment(-1.0, -1.0);                             // fill
                                monkey.SetWeight(1.0, 0.0);                                  // expand on X axis
                                monkey.Show();
                                infoBox.PackEnd(monkey);
                            }

                            {
                                var textBox = new ElmSharp.Box(infoBox);
                                textBox.SetAlignment(-1.0, -1.0);                             // fill
                                textBox.SetWeight(1.0, 0.0);                                  // expand on X axis
                                textBox.Show();
                                infoBox.PackEnd(textBox);

                                {
                                    var title = new NLabel(textBox)
                                    {
                                        Text           = pin.Label,
                                        FontAttributes = FontAttributes.Bold,
                                        TextColor      = ElmSharp.Color.White,
                                    };
                                    title.SetAlignment(-1.0, -1.0);                                 // fill
                                    title.SetWeight(1.0, 0.0);                                      // expand on X axis
                                    title.Show();
                                    textBox.PackEnd(title);
                                }

                                {
                                    var subtitle = new NLabel(textBox)
                                    {
                                        Text      = pin.Address,
                                        TextColor = ElmSharp.Color.White,
                                    };
                                    subtitle.SetAlignment(-1.0, -1.0);                                 // fill
                                    subtitle.SetWeight(1.0, 0.0);                                      // expand on X axis
                                    subtitle.Show();
                                    textBox.PackEnd(subtitle);
                                }
                            }

                            {
                                var info = new ElmSharp.Image(infoBox);
                                info.Load(InfoPath);
                                info.SetAlignment(-1.0, -1.0);                             // fill
                                info.SetWeight(1.0, 0.0);                                  // expand on X axis
                                info.Show();
                                infoBox.PackEnd(info);
                            }
                        }
                    }

                    {
                        var expander = new ElmSharp.Box(window);
                        expander.SetAlignment(-1.0, -1.0);                     // fill
                        expander.SetWeight(1.0, 1.0);                          // expand
                        expander.Show();
                        window.PackEnd(expander);
                    }

                    window.Resize(width, height);

                    Control.Add(new Overlay(coordinates, window));
                }

                isDrawn = true;
            }
        }
Exemplo n.º 38
0
        private static void ApplyDocument(Control control, Element element, MethodInfo[] pageMethods, ContentPage Page, bool parent = false)
        {
            Control child = null;

            if (!parent)
            {
                string x = GetNamespace(element.namespaceURI);
                if (string.IsNullOrWhiteSpace(x))
                {
                    x = element.tagName;
                }
                else
                {
                    x = x + "." + element.tagName;
                }
                child = Activator.CreateInstance(Type.GetType(x)).As <Control>();
            }
            else
            {
                child = control;
            }
            var fields = child.GetType().GetFields();
            var props  = child.GetType().GetProperties();

            var events = child.GetType().GetEvents();

            //TODO CACHE MethodInfos.
            // CACHE DomParser.
            for (uint i = 0; i < element.attributes.length; i++)
            {
                try
                {
                    var  attribute = element.attributes[i];
                    bool found     = false;
                    for (int j = 0; j < fields.Length; j++)
                    {
                        if (fields[j].Name == attribute.nodeName)
                        {
                            fields[j].SetValue(child, attribute.value);
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        for (int j = 0; j < props.Length; j++)
                        {
                            if (props[j].Name == attribute.nodeName)
                            {
                                props[j].SetValue(child, attribute.value);
                                found = true;
                                break;
                            }
                        }
                    }
                    if (!found && !string.IsNullOrWhiteSpace(attribute.nodeName))
                    {
                        for (int j = 0; j < events.Length; j++)
                        {
                            if (events[j].Name == attribute.nodeName)
                            {
                                for (int jj = 0; jj < pageMethods.Length; jj++)
                                {
                                    if (pageMethods[jj].Name == attribute.value)
                                    {
                                        events[j].AddEventHandler(child, pageMethods[jj].CreateDelegate(Page));


                                        ////                            Delegate handler =
                                        ////Delegate.CreateDelegate(eventInfo.EventHandlerType,
                                        ////                        p,
                                        ////                        methodInfo);
                                        ////                            eventInfo.AddEventHandler(p, handler);

                                        //events[j].AddEventHandler(child, (pageMethods[jj].CreateDelegate()));
                                        break;
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
                catch (Exception)
                {
                }
            }

            if (element.childElementCount > 0)
            {
                for (uint i = 0; i < element.childElementCount; i++)
                {
                    ApplyDocument(child, element.children[i], pageMethods, Page, false);
                }
            }

            if (!parent)
            {
                control.Add(child);
            }
        }
Exemplo n.º 39
0
        public static object Add(this Control parent, WinFormItem winFormItem)
        {
            if (!winFormItem.Caption.IsEmpty())
            {
                Label l;
                if (winFormItem.CellAddress == WinFormItem.CellAddressDefault)
                {
                    l = parent.Add <Label>(new WinFormItem("Label_" + winFormItem.Name)
                    {
                        CellAddress = new Pair <int>(winFormItem.CellAddress.X, winFormItem.CellAddress.Y)
                    });
                    winFormItem.CellAddress = new Pair <int>(winFormItem.CellAddress.X + 1, winFormItem.CellAddress.Y);
                }
                else
                {
                    l = parent.Add <Label>(new WinFormItem("Label_" + winFormItem.Name));
                }
                l.Text = winFormItem.Caption;
            }
            if (winFormItem.PresentationType == null)
            {
                if (winFormItem.DataType == typeof(bool))
                {
                    winFormItem.PresentationType = typeof(CheckBox);
                    winFormItem.Clear();
                    winFormItem.Add(new WinFormItem("Да")
                    {
                        Value = true
                    });
                    winFormItem.Add(new WinFormItem("Нет")
                    {
                        Value = false
                    });
                    winFormItem.ControlTrigger = (i, c) =>
                    {
                        CheckBox chkBox = c as CheckBox;
                        chkBox.Text            = (bool)i.Value ? "Да" : "Нет";
                        chkBox.Checked         = (bool)i.Value;
                        chkBox.CheckedChanged += (ctrl, e) =>
                        {
                            CheckBox cb = (CheckBox)ctrl;
                            chkBox.Text = cb.Checked ? "Да" : "Нет";
                        };
                    };
                }
                else if (winFormItem.DataType == typeof(DateTime))
                {
                    winFormItem.PresentationType = typeof(DateEdit);
                }
                else if (!winFormItem.SuperForm.IsEmpty())
                {
                    winFormItem.PresentationType = typeof(TextBuX);
                }
            }
            if ((winFormItem.PresentationType == null || winFormItem.PresentationType.IsSubclassOf(typeof(ListBox))) &&
                winFormItem.Count() > 0 && winFormItem.SuperForm.IsEmpty() && IsSimpleType(winFormItem.DataType))
            {
                winFormItem.PresentationType = typeof(ComboBox);
                winFormItem.ControlTrigger   = (item, c) =>
                {
                    ComboBox cmb = c as ComboBox;
                    if (item.Mask.ToLower() == "lock")
                    {
                        cmb.DropDownStyle = ComboBoxStyle.DropDownList;
                    }
                    if (!string.IsNullOrEmpty(item.Format))
                    {
                        cmb.FormatString = item.Format;
                    }
                    cmb.Items.AddRange(item.ToArray());
                    cmb.DataSource = item.Select(wfi => wfi.Name).ToList();
                    cmb.DataBindings.Add("Text", item, "Value");

                    Type t = winFormItem.DataType;
                    if (t.IsNumeric())
                    {
                        var itemWithData = winFormItem.FirstOrDefault(d => d.Value.Equals(winFormItem.Value));
                        if (itemWithData != null)
                        {
                            cmb.Text = itemWithData.Caption;
                        }
                    }
                };
            }
            else if ((winFormItem.PresentationType == typeof(RadioGroup) && winFormItem.Count() > 0 &&
                      winFormItem.SuperForm.IsEmpty() && IsSimpleType(winFormItem.DataType)))
            {
                winFormItem.ControlTrigger = (i, c) =>
                {
                    RadioGroup rg = c as RadioGroup;
                    rg.Items.AddRange(i.Select(item => item.Name).ToArray());
                    if (rg.Items.Count > 2)
                    {
                        rg.Height = Math.Max(rg.Height, rg.Items.Count * rg.Font.Height * 2);
                    }
                    else
                    {
                        rg.Height = rg.Font.Height * 5;
                    }

                    if (winFormItem.Value != null)
                    {
                        rg.Text = winFormItem.Value.ToString();
                    }
                };
            }
            else if (winFormItem.PresentationType == null)
            {
                winFormItem.PresentationType = typeof(TextBox);
            }
            return(AddInternal(parent, winFormItem));
        }
Exemplo n.º 40
0
 protected override void SetContainerContent(Gtk.Widget content)
 {
     Control.Add(content);
 }
Exemplo n.º 41
0
        protected void InitializeControls(Control parent, int top)
        {
            foreach (Label label in LabelsToShow)
            {
                parent.Add(label);
            }

            for (int i = 0; i < LabelsToShow.Count; i++)
            {
                Label label = LabelsToShow[i];
                label.Left = 4;
                label.Width = label.Parent.Width - 4;
                if (i == 0)
                    label.Top = top;
                else
                {
                    label.Top = LabelsToShow[i - 1].Top + LabelsToShow[i - 1].Height + 2;
                }
                if (label is RappingLabel)
                {
                    label.Height = label.Parent.Height - label.Top - 4;
                    label.Alignment = Alignment.TopLeft;
                    label.TextColor = Microsoft.Xna.Framework.Color.LightGray;
                    (label as RappingLabel).WrapText();
                }
            }
        }
Exemplo n.º 42
0
        private void SetProperties(Control c, Control parent, Manager manager)
        {
            c.Name = Name;
            //c.Top = Top < 0 ? manager.GraphicsDevice.Viewport.Height + Top : Top;
            //c.Left = Left < 0 ? manager.GraphicsDevice.Viewport.Width + Left : Left;
            if (!string.IsNullOrEmpty(Parent))
            {
                c.Top = Top < 0 ? parent.GetControl(Parent).Height + Top : Top;
                c.Left = Left < 0 ? parent.GetControl(Parent).Width + Left : Left;
            }
            else
            {
                c.Top = Top < 0 ? parent.Height + Top : Top;
                c.Left = Left < 0 ? parent.Width + Left : Left;
            }

            c.Width = Width;
            c.Height = Height;

            c.StayOnBack = StayOnBack;
            c.StayOnTop = StayOnTop;
            c.Passive = Passive;
            c.Enabled = Enabled;

            if (TextColor != Color.Transparent)
                c.TextColor = TextColor;
            else
                c.TextColor = Color.White;

            if (BackColor != Color.Transparent)
                c.BackColor = BackColor;

            if (Color != Color.Transparent)
                c.Color = Color;

            c.Tag = this;
            c.Visible = Visible;

            if (!string.IsNullOrEmpty(ToolTip))
            {
                ToolTip = ToolTip.Trim();
                c.ToolTipType = typeof(EnhancedToolTip);
                c.ToolTip.Text = ToolTip;
                c.ToolTip.MaximumWidth = 240;
                c.ToolTip.MinimumWidth = 240;
                c.ToolTip.Height = ToolTip.Split(new char[] { '\n' }).Length * 20;
            }

            if (!string.IsNullOrEmpty(Parent))
                c.Parent = parent.GetControl(Parent);
            else
                parent.Add(c);
        }
Exemplo n.º 43
0
		public void Show(Control.ControlCollection parent)
		{
			this.Dock = DockStyle.Fill;
			parent.Add(this);
		}