Пример #1
0
        public DropDownBoxListWindow(IListDataProvider provider, WindowType windowType) : base(windowType)
        {
            Accessible.Name = "DropDownBoxListWindow";

            this.DataProvider = provider;
            this.TransientFor = IdeApp.Workbench.RootWindow;
            this.TypeHint     = Gdk.WindowTypeHint.DropdownMenu;
            this.Decorated    = false;
            this.BorderWidth  = 1;
            list = new ListWidget(this);
            list.Accessible.Name = "DropDownBoxListWindow.List";

            list.SelectItem += delegate {
                var sel = list.Selection;
                if (sel >= 0 && sel < DataProvider.IconCount)
                {
                    DataProvider.ActivateItem(sel);
                    Destroy();
                }
            };
            SetSizeRequest(list.WidthRequest + WidthModifier, list.HeightRequest);
            vScrollbar = new ScrolledWindow();
            vScrollbar.VScrollbar.SizeAllocated += (o, args) => {
                var minWidth = list.WidthRequest + args.Allocation.Width;
                if (this.Allocation.Width < minWidth)
                {
                    SetSizeRequest(minWidth, list.HeightRequest);
                }
            };
            vScrollbar.Child = list;
            var vbox = new VBox();

            vbox.PackStart(vScrollbar, true, true, 0);
            Add(vbox);
        }
		public DropDownBoxListWindow (IListDataProvider provider) : base (WindowType.Popup)
		{
			this.DataProvider = provider;
			this.TransientFor = IdeApp.Workbench.RootWindow;
			this.TypeHint = Gdk.WindowTypeHint.Menu;
			this.BorderWidth = 1;
			this.Events |= Gdk.EventMask.KeyPressMask;
			list = new ListWidget (this);
			list.SelectItem += delegate {
				var sel = list.Selection;
				if (sel >= 0 && sel < DataProvider.IconCount) {
					DataProvider.ActivateItem (sel);
					Destroy ();
				}
			};
			SetSizeRequest (list.WidthRequest, list.HeightRequest);
			vScrollbar = new ScrolledWindow ();
			vScrollbar.VScrollbar.SizeAllocated += (o, args) => {
				var minWidth = list.WidthRequest + args.Allocation.Width;
				if (this.Allocation.Width < minWidth)
					SetSizeRequest (minWidth, list.HeightRequest);
			};
			vScrollbar.Child = list;
			var vbox = new VBox ();
			vbox.PackStart (vScrollbar, true, true, 0);
			Add (vbox);
		}
		public DropDownBoxListWindow (IListDataProvider provider) : base(Gtk.WindowType.Popup)
		{
			this.DataProvider = provider;
			this.TransientFor = MonoDevelop.Ide.IdeApp.Workbench.RootWindow;
			this.TypeHint = Gdk.WindowTypeHint.Menu;
			this.BorderWidth = 1;
			this.Events |= Gdk.EventMask.KeyPressMask;
			hBox = new HBox ();
			list = new ListWidget (this);
			list.SelectItem += delegate {
				var sel = list.Selection;
				if (sel >= 0 && sel < DataProvider.IconCount) {
					DataProvider.ActivateItem (sel);
					Destroy ();
				}
			};
			
			list.ScrollEvent += HandleListScrollEvent;
			list.SizeAllocated += delegate {
				QueueResize ();
			};
			list.PageChanged += HandleListPageChanged;
			hBox.PackStart (list, true, true, 0);
			
			vScrollbar = new VScrollbar (null);
			vScrollbar.ValueChanged += delegate {
				list.ForcePage ((int)vScrollbar.Value);
			};
			
			hBox.PackStart (vScrollbar, false, false, 0);
			Add (hBox);
			ShowAll ();
		}
Пример #4
0
        public DropDownBoxListWindow(IListDataProvider provider) : base(Gtk.WindowType.Popup)
        {
            this.DataProvider = provider;
            this.TransientFor = MonoDevelop.Ide.IdeApp.Workbench.RootWindow;
            this.TypeHint     = Gdk.WindowTypeHint.Menu;
            this.BorderWidth  = 1;
            this.Events      |= Gdk.EventMask.KeyPressMask;
            list             = new ListWidget(this);
            list.SelectItem += delegate {
                var sel = list.Selection;
                if (sel >= 0 && sel < DataProvider.IconCount)
                {
                    DataProvider.ActivateItem(sel);
                    Destroy();
                }
            };
            SetSizeRequest(list.WidthRequest, list.HeightRequest);
            vScrollbar = new ScrolledWindow();
            vScrollbar.VScrollbar.SizeAllocated += (object o, SizeAllocatedArgs args) => {
                var minWidth = list.WidthRequest + args.Allocation.Width;
                if (this.Allocation.Width < minWidth)
                {
                    SetSizeRequest(minWidth, list.HeightRequest);
                }
            };
            vScrollbar.Child = list;
            var vbox = new VBox();

            vbox.PackStart(vScrollbar, true, true, 0);
            Add(vbox);
        }
        public DropDownBoxListWindow(IListDataProvider provider) : base(Gtk.WindowType.Popup)
        {
            this.DataProvider = provider;
            this.TransientFor = MonoDevelop.Ide.IdeApp.Workbench.RootWindow;
            this.TypeHint     = Gdk.WindowTypeHint.Menu;
            this.BorderWidth  = 1;
            this.Events      |= Gdk.EventMask.KeyPressMask;
            hBox             = new HBox();
            list             = new ListWidget(this);
            list.SelectItem += delegate {
                DataProvider.ActivateItem(list.Selection);
                Destroy();
            };

            list.ScrollEvent   += HandleListScrollEvent;
            list.SizeAllocated += delegate {
                QueueResize();
            };
            list.PageChanged += HandleListPageChanged;
            hBox.PackStart(list, true, true, 0);

            vScrollbar = new VScrollbar(null);
            vScrollbar.ValueChanged += delegate {
                list.ForcePage((int)vScrollbar.Value);
            };

            hBox.PackStart(vScrollbar, false, false, 0);
            Add(hBox);
            ShowAll();
        }
Пример #6
0
        public CraftingTab(GameState gameState, List <Recipe> recipies = null) : base(gameState)
        {
            Icon         = new Sprite(Ressources.TileIcons, new Point(4, 2));
            CraftingList = new ListWidget
            {
                Dock       = Dock.Fill,
                ItemHeight = 64,
            };

            var craftButton = new Button
            {
                Text = "Craft",
                Dock = Dock.Bottom,
            };

            craftButton.MouseClick += Craft;

            foreach (var recipe in recipies ?? RECIPIES.HandCrafted)
            {
                CraftingList.AddItem(new CraftingListItem(recipe, GameState.LocalPlayer.Entity.GetComponent <Inventory>().Content));
            }

            Content = new Container()
            {
                Childrens =
                {
                    new Label {
                        Text = "Crafting", Font = Ressources.FontAlagard, Dock = Dock.Top
                    },
                    craftButton, CraftingList,
                }
            };
        }
Пример #7
0
        public DropDownBoxListWindow(IListDataProvider provider, WindowType windowType) : base(windowType)
        {
            Accessible.Name = "DropDownBoxListWindow";

            this.DataProvider = provider;
            this.TransientFor = IdeApp.Workbench.RootWindow;
            this.TypeHint     = Gdk.WindowTypeHint.DropdownMenu;
            this.Decorated    = false;
            this.BorderWidth  = 1;
            list = new ListWidget(this);
            list.Accessible.Name = "DropDownBoxListWindow.List";

            list.SelectItem += delegate {
                var sel = list.Selection;
                if (sel >= 0 && sel < DataProvider.IconCount)
                {
                    try {
                        DataProvider.ActivateItem(sel);
                        // This is so parent window of dropdown regains focus
                        TransientFor?.Present();
                    } catch (Exception ex) {
                        LoggingService.LogInternalError("Offset seems to be out of sync with the snapshot.", ex);
                    }

                    Destroy();
                }
            };
            SetSizeRequest(list.WidthRequest + WidthModifier, list.HeightRequest);
            vScrollbar = new ScrolledWindow();
            vScrollbar.VScrollbar.SizeAllocated += (o, args) => {
                var minWidth = list.WidthRequest + args.Allocation.Width;
                if (this.Allocation.Width < minWidth)
                {
                    SetSizeRequest(minWidth, list.HeightRequest);
                }
            };
            vScrollbar.Child = list;
            var vbox = new VBox();

            vbox.PackStart(vScrollbar, true, true, 0);
            Add(vbox);
        }
Пример #8
0
        public DropDownBoxListWindow(DropDownBox parent) : base(Gtk.WindowType.Popup)
        {
            this.parent       = parent;
            this.TransientFor = MonoDevelop.Ide.IdeApp.Workbench.RootWindow;
            this.TypeHint     = Gdk.WindowTypeHint.Menu;
            this.BorderWidth  = 1;

            hBox             = new HBox();
            list             = new ListWidget(this);
            list.SelectItem += delegate {
                parent.SetItem(list.Selection);
                Destroy();
            };

            list.ScrollEvent += delegate(object o, ScrollEventArgs args) {
                if (args.Event.Direction == Gdk.ScrollDirection.Up)
                {
                    vScrollbar.Value--;
                }
                else if (args.Event.Direction == Gdk.ScrollDirection.Down)
                {
                    vScrollbar.Value++;
                }
            };
            list.SizeAllocated += delegate {
                QueueResize();
            };
            list.PageChanged += HandleListPageChanged;
            hBox.PackStart(list, true, true, 0);

            vScrollbar = new VScrollbar(null);
            vScrollbar.ValueChanged += delegate {
                list.ForcePage((int)vScrollbar.Value);
            };

            hBox.PackStart(vScrollbar, false, false, 0);
            Add(hBox);
            ShowAll();
        }
Пример #9
0
        public TabLoadWorld()
        {
            Icon = new Sprite(Ressources.TileIcons, new Point(2, 2));

            var title = new Label
            {
                Text = "Load World",
                Font = Ressources.FontAlagard,
                Dock = Dock.Top
            };

            var saveList = new ListWidget()
            {
                Dock = Dock.Fill
            };

            var loadButton = new Button
            {
                Text = "Load",
                Dock = Dock.Bottom
            }
            .RegisterMouseClickEvent((sender) =>
            {
                if (saveList.SelectedItem != null)
                {
                    var item = (ListItemText)saveList.SelectedItem;
                    Game.Play(item.Text);
                }
            });

            Content = new Container(title, loadButton, saveList);

            var s = Directory.GetDirectories(Game.GetSaveFolder());

            foreach (var save in s)
            {
                saveList.AddItem(new ListItemText(save));
            }
        }
Пример #10
0
        public MenuScreen(Composite parent)
            : base(parent)
        {
            AddControl(new SpacerWidget(this, 1, 5), HorizontalJustify.Center);
            var titleWidget = new TextWidget(this, "Star Rogue");
            AddControl(new BoxWidget(titleWidget, 1), HorizontalJustify.Center);
            //AddControl(titleWidget, HorizontalJustify.Center);

            var stackedComposite = new StackedComposite(this);
            NewListWidget = new ListWidget<Option>(stackedComposite);
            ContinueListWidget = new ListWidget<Option>(stackedComposite);

            //stackedComposite.AddControl(new LayoutData(NewListWidget) { HorizontalJustify = HorizontalJustify.Center, VerticalJustify = VerticalJustify.Center });
            //stackedComposite.AddControl(new LayoutData(ContinueListWidget) { HorizontalJustify = HorizontalJustify.Center, VerticalJustify = VerticalJustify.Center });
            stackedComposite.AddControl(NewListWidget);
            stackedComposite.AddControl(ContinueListWidget);

            AddControl(new SpacerWidget(this, 1, 5), HorizontalJustify.Center);
            //AddControl(new BoxWidget(stackedComposite, 1), HorizontalJustify.Center);
            AddControl(stackedComposite, HorizontalJustify.Center);
            //AddControl(ContinueListWidget);
        }
		public DropDownBoxListWindow (IListDataProvider provider) : base(Gtk.WindowType.Popup)
		{
			this.DataProvider = provider;
			this.TransientFor = MonoDevelop.Ide.IdeApp.Workbench.RootWindow;
			this.TypeHint = Gdk.WindowTypeHint.Menu;
			this.BorderWidth = 1;
			
			hBox = new HBox ();
			list = new ListWidget (this);
			list.SelectItem += delegate {
				DataProvider.ActivateItem (list.Selection);
				Destroy ();
			};
			
			list.ScrollEvent += delegate(object o, ScrollEventArgs args) {
				if (args.Event.Direction == Gdk.ScrollDirection.Up) {
					vScrollbar.Value--;
				} else if (args.Event.Direction == Gdk.ScrollDirection.Down) {
					vScrollbar.Value++;
				}
			};
			list.SizeAllocated += delegate {
				QueueResize ();
			};
			list.PageChanged += HandleListPageChanged;
			hBox.PackStart (list, true, true, 0);
			
			vScrollbar = new VScrollbar (null);
			vScrollbar.ValueChanged += delegate {
				list.ForcePage ((int)vScrollbar.Value);
			};
			
			hBox.PackStart (vScrollbar, false, false, 0);
			Add (hBox);
			ShowAll ();
		}
Пример #12
0
        // Executors
        private static Window CreateWindow9_2(string path)
        {
            var window = new Window("window9_2", Path.Combine(path, @"generic/bg.raw"));

            window.AddChild(new RawButton("window9_home", Path.Combine(path, @"generic/home.raw"), Path.Combine(path, @"generic/home.raw"), 383, 247)
            {
                OnRelease = () => mApplication.SetFocusedWindow("window1")
            });


            var list = new ListWidget("list", 10, 75, new[] { 300 }, TextTable.CreateOffset(6, 25));

            window.OnShow = () =>
            {
                var executors = mDeviceControl.SettingsStorage.Load().Executors;

                list.Items = executors.ConvertAll(e => new ListWidget.Item {
                    Column1 = e, Id = e
                }).ToArray();
            };
            window.AddChild(list);


            window.AddChild(new RawButton("", Path.Combine(path, "9/2/bt_up.raw"), Path.Combine(path, "9/2/bt_up_pr.raw"), 340, 175)
            {
                OnRelease = list.Up
            });


            window.AddChild(new RawButton("", Path.Combine(path, "9/2/bt_choose.raw"), Path.Combine(path, "9/2/bt_choose_pr.raw"), 340, 135)
            {
                OnRelease = () =>
                {
                    var settings = mDeviceControl.SettingsStorage.Load();

                    settings.Executors = list.Items.ToList().ConvertAll(i => i.Column1);

                    settings.LastUsedExecutor = (string)list.CurrentSelection;

                    mDeviceControl.SettingsStorage.Save(settings);

                    var rv = mApplication.GetWindows().First(w => w.Name == "window2") as Window;

                    if (rv == null)
                    {
                        return;
                    }

                    rv.OnShow();
                    mApplication.SetFocusedWindow(rv);
                }
            });

            window.AddChild(new RawButton("", Path.Combine(path, "9/2/bt_down.raw"), Path.Combine(path, "9/2/bt_down_pr.raw"), 340, 65)
            {
                OnRelease = list.Down
            });

            window.AddChild(new RawButton("", Path.Combine(path, "9/2/bt_add.raw"), Path.Combine(path, "9/2/bt_add_pr.raw"), 320, 5)//340, 5)
            {
                OnRelease = () =>
                {
                    mKeyboardWindow.OnEnter = returnText =>
                    {
                        if (!string.IsNullOrWhiteSpace(returnText))
                        {
                            var newItems =
                                new ListWidget.Item[list.Items.Length + 1];

                            Array.Copy(list.Items, newItems, list.Items.Length);

                            newItems[list.Items.Length] =
                                new ListWidget.Item
                            {
                                Column1 = returnText, Id = returnText
                            };

                            list.Items = newItems;
                        }
                    };

                    mKeyboardWindow.ReturnWindow = "window9_2";

                    mApplication.SetFocusedWindow("keyboard_window");
                }
            });

            window.AddChild(new RawButton("", Path.Combine(path, "9/2/bt_delete.raw"), Path.Combine(path, "9/2/bt_delete_pr.raw"), 185, 5)//205, 5)
            {
                OnRelease = () =>
                {
                    var newItems = list.Items.ToList();

                    newItems.RemoveAll(i => i.Id == list.CurrentSelection);

                    list.Items = newItems.ToArray();
                }
            });

            window.AddChild(new RawButton("", Path.Combine(path, "9/2/bt_back.raw"), Path.Combine(path, "9/2/bt_back_pr.raw"), 20, 5)
            {
                OnRelease = () => mApplication.SetFocusedWindow("window2")
            });

            return(window);
        }
Пример #13
0
        // работа с архивом. копирование / удаление
        private static Window CreateWindow10_1(string path)
        {
            var window = new Window("window10_1", Path.Combine(path, @"generic/bg.raw"));

            window.AddChild(new RawButton("window10_1.home", Path.Combine(path, @"generic/home.raw"), Path.Combine(path, @"generic/home.raw"), 383, 247)
            {
                OnRelease = () => mApplication.SetFocusedWindow("window1")
            });

            var list = new ListWidget("list", 10, 70, new [] { 130, 180 }, TextTable.CreateOffset(6, 26));

            window.OnShow = () =>
            {
                var descs = mDeviceControl.GetSavedReportsDescs().OrderByDescending(d => d.Date);

                var items = new ListWidget.Item[descs.Count()];

                var i = 0;
                foreach (var desc in descs)
                {
                    items[i] = new ListWidget.Item {
                        Column1 = desc.SampleName, Column2 = desc.Date.ToString(CultureInfo.GetCultureInfo("ru-RU")), Id = desc.Id
                    };
                    i++;
                }

                list.Items = items;
            };
            window.AddChild(list);


            window.AddChild(new RawButton("window10_1.btn_up", Path.Combine(path, @"10/1/bt_up.raw"), Path.Combine(path, @"10/1/bt_up_press.raw"), 333, 175)
            {
                OnRelease = list.Up
            });
            //window10_1.AddChild(new RawButton("window10_1.btn_mark", Path.Combine(path, @"10/1/bt_mark.raw"), Path.Combine(path, @"10/1/bt_mark_press.raw"), 333, ToVgY(145)) { PixelFormat = pixelFormat });
            window.AddChild(new RawButton("window10_1.btn_down", Path.Combine(path, @"10/1/bt_down.raw"), Path.Combine(path, @"10/1/bt_down_press.raw"), 333, 60)
            {
                OnRelease = list.Down
            });

            window.AddChild(new RawButton("window10_1.btn_view", Path.Combine(path, @"10/1/bt_view.raw"),
                                          Path.Combine(path, @"10/1/bt_view_press.raw"), 5, 5)
            {
                OnRelease = () => mMeasureController.ShowReport((Guid)list.CurrentSelection)
            });

            window.AddChild(new RawButton("window10_1.btn_copy", Path.Combine(path, @"10/1/bt_copy.raw"), Path.Combine(path, @"10/1/bt_copy_press.raw"), 125, 5)
            {
                OnRelease = () => mMeasureController.CopyReport((Guid)list.CurrentSelection)
            });
            window.AddChild(new RawButton("window10_1.btn_delete", Path.Combine(path, @"10/1/bt_delete.raw"), Path.Combine(path, @"10/1/bt_delete_press.raw"), 245, 5)
            {
                OnRelease = () =>
                {
                    var id = list.CurrentSelection;

                    if (id != null)
                    {
                        mDeviceControl.RemoveReports(new [] { (Guid)id });
                    }

                    window.OnShow();

                    window.Invalidate();
                }
            });

            //window10_1.AddChild(new RawButton("window10_1.btn_filter", Path.Combine(path, @"10/1/bt_filter.raw"), Path.Combine(path, @"10/1/bt_filter_press.raw"), 365, 5) { PixelFormat = pixelFormat });


            return(window);
        }
Пример #14
0
    public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
    {
        if (type == typeof(APIResultWidget))
        {
            switch ((string)dictionary["Type"])
            {
            case "weather":
            {
                WeatherWidget x = new WeatherWidget();
                x.Location = (string)dictionary["Location"];
                x.Current  = (CurrentWeather)dictionary["Current"];
                //x.Forcast = (List<WeatherForcastItem>)dictionary["Forcast"];
                System.Collections.ArrayList itemss = ((System.Collections.ArrayList)dictionary["Forcast"]);
                foreach (var item in itemss)
                {
                    x.Forcast.Add(serializer.ConvertToType <WeatherForcastItem>(item));
                }
                return(x);
            };

            case "text":
            {
                TextWidget x = new TextWidget();
                x.Content = (string)dictionary["Content"];
                return(x);
            };

            case "keyValueText":
            {
                KeyValueTextWidget x = new KeyValueTextWidget();
                x.Key = (string)dictionary["Key"];
                x.Key = (string)dictionary["Value"];
                x.Key = (string)dictionary["ValueURL"];
                return(x);
            };

            case "keyValuesText":
            {
                KeyValuesTextWidget x = new KeyValuesTextWidget();
                x.Key = (string)dictionary["Key"];
                //x.Values = (List<ValueItem>)dictionary["ValueItem"];
                System.Collections.ArrayList itemss = ((System.Collections.ArrayList)dictionary["ValueItem"]);
                foreach (var item in itemss)
                {
                    x.Values.Add(serializer.ConvertToType <ValueItem>(item));
                }
                return(x);
            };

            case "url":
            {
                URLWidget x = new URLWidget();
                x.ThumbnailImageURL = (string)dictionary["ThumbnailImageURL"];
                x.Title             = (string)dictionary["Title"];
                x.URL         = (string)dictionary["URL"];
                x.HTMLContent = (string)dictionary["HTMLContent"];
                return(x);
            };

            case "map":
            {
                MapWidget x = new MapWidget();
                System.Collections.ArrayList itemss = ((System.Collections.ArrayList)dictionary["Pins"]);
                foreach (var item in itemss)
                {
                    x.Pins.Add(serializer.ConvertToType <MapPoint>(item));
                }
                //x.Pins = (List<MapPoint>)dictionary["Pins"];
                return(x);
            };

            case "image":
            {
                ImageWidget x = new ImageWidget();
                x.Title        = (string)dictionary["Title"];
                x.ImageURL     = (string)dictionary["ImageURL"];
                x.ThumbnailURL = (string)dictionary["ThumbnailURL"];
                x.PageURL      = (string)dictionary["PageURL"];
                return(x);
            };

            case "html":
            {
                HTMLWidget x = new HTMLWidget();
                x.Title = (string)dictionary["Title"];
                x.HTML  = (string)dictionary["HTML"];
                return(x);
            };

            case "entity":
            {
                EntityWidget x = new EntityWidget();
                x.SubType  = (string)dictionary["SubType"];
                x.Title    = (string)dictionary["Title"];
                x.Abstract = (string)dictionary["Abstract"];
                x.ImageURL = (string)dictionary["ImageURL"];
                x.Url      = (string)dictionary["Url"];
                return(x);
            };

            case "chart":
            {
                ChartWidget x = new ChartWidget();
                x.Title = (string)dictionary["Title"];
                //x.Categories = (List<string>)dictionary["Categories"];
                System.Collections.ArrayList itemss = ((System.Collections.ArrayList)dictionary["Categories"]);
                foreach (var item in itemss)
                {
                    x.Categories.Add(serializer.ConvertToType <string>(item));
                }
                System.Collections.ArrayList itemss2 = ((System.Collections.ArrayList)dictionary["Data"]);
                foreach (var item in itemss2)
                {
                    x.Data.Add(serializer.ConvertToType <ChartsData>(item));
                }
                //x.Data = (List<ChartsData>)dictionary["Data"];
                return(x);
            };

            case "businessEntity":
            {
                BusinessEntityWidget x = new BusinessEntityWidget();
                x.SubType  = (string)dictionary["SubType"];
                x.Title    = (string)dictionary["Title"];
                x.Abstract = (string)dictionary["Abstract"];
                x.ImageURL = (string)dictionary["ImageURL"];
                x.URL      = (string)dictionary["URL"];
                //x.Attributes = (List<KeyValueTextWidget>)dictionary["Attributes"];
                System.Collections.ArrayList itemss = ((System.Collections.ArrayList)dictionary["Attributes"]);
                foreach (var item in itemss)
                {
                    x.Attributes.Add(serializer.ConvertToType <KeyValueTextWidget>(item));
                }
                x.Address = (string)dictionary["Address"];
                x.Phone   = (string)dictionary["Phone"];
                x.Lat     = (double)dictionary["Lat"];
                x.Lng     = (double)dictionary["Lng"];
                System.Collections.ArrayList itemss2 = ((System.Collections.ArrayList)dictionary["OtherURLs"]);
                foreach (var item in itemss2)
                {
                    x.OtherURLs.Add(serializer.ConvertToType <URLWidget>(item));
                }
                //x.OtherURLs = (List<URLWidget>)dictionary["OtherURLs"];
                return(x);
            };

            case "list":
            {
                switch ((string)dictionary["SubType"])
                {
                case null:
                {
                    ListWidget x = new ListWidget();
                    x.Title = (string)dictionary["Title"];
                    System.Collections.ArrayList itemss = ((System.Collections.ArrayList)dictionary["Items"]);
                    foreach (var item in itemss)
                    {
                        x.Items.Add(serializer.ConvertToType <APIResultWidget>(item));
                    }
                    return(x);
                };

                case "videos":
                {
                    ListOfVideosWidget           x      = new ListOfVideosWidget();
                    System.Collections.ArrayList itemss = ((System.Collections.ArrayList)dictionary["Items"]);
                    foreach (var item in itemss)
                    {
                        x.Items.Add(serializer.ConvertToType <URLWidget>(item));
                    }
                    return(x);
                };

                case "images":
                {
                    ListOfImagesWidget           x      = new ListOfImagesWidget();
                    System.Collections.ArrayList itemss = ((System.Collections.ArrayList)dictionary["Items"]);
                    foreach (var item in itemss)
                    {
                        x.Items.Add(serializer.ConvertToType <ImageWidget>(item));
                    }
                    return(x);
                };

                case "webResults":
                {
                    ListOfWebsitesWidget         x      = new ListOfWebsitesWidget();
                    System.Collections.ArrayList itemss = ((System.Collections.ArrayList)dictionary["Items"]);
                    foreach (var item in itemss)
                    {
                        x.Items.Add(serializer.ConvertToType <URLWidget>(item));
                    }
                    return(x);
                };

                case "businesses":
                {
                    ListOfBusinessesWidget x = new ListOfBusinessesWidget();
                    x.Title = (string)dictionary["Title"];
                    System.Collections.ArrayList itemss = ((System.Collections.ArrayList)dictionary["Items"]);
                    foreach (var item in itemss)
                    {
                        x.Items.Add(serializer.ConvertToType <BusinessEntityWidget>(item));
                    }
                    return(x);
                };
                }
            }; break;
            }
        }
        else                                   //in case of objects not inheriting from the abstract class, in this case we identify each one by something else, not "type"
        {
            if (dictionary.ContainsKey("Day")) //WeatherForcastItem
            {
                WeatherForcastItem x = new WeatherForcastItem();
                x.Day     = (string)dictionary["Day"];
                x.Hi      = (string)dictionary["Hi"];
                x.Lo      = (string)dictionary["Lo"];
                x.Status  = (string)dictionary["Status"];
                x.IconURL = (string)dictionary["IconURL"];
                return(x);
            }
            else if (dictionary.ContainsKey("Temprature"))     // CurrentWeather
            {
                CurrentWeather x = new CurrentWeather();
                x.Temprature    = (string)dictionary["Temprature"];
                x.Status        = (string)dictionary["Status"];
                x.WindSpeed     = (string)dictionary["WindSpeed"];
                x.WindDirection = (string)dictionary["WindDirection"];
                x.Humidity      = (string)dictionary["Humidity"];
                x.IconURL       = (string)dictionary["IconURL"];
                x.IsNight       = (string)dictionary["IsNight"];
                return(x);
            }
            else if (dictionary.ContainsKey("Lat"))     //MapPoint
            {
                MapPoint x = new MapPoint();
                x.Title = (string)dictionary["Title"];
                x.Lat   = (double)dictionary["Lat"];
                x.Lng   = (double)dictionary["Lng"];
                return(x);
            }
            else if (dictionary.ContainsKey("Value"))     //ValueItem
            {
                ValueItem x = new ValueItem();
                x.Value    = (string)dictionary["Value"];
                x.ValueURL = (string)dictionary["ValueURL"];
                return(x);
            }
            else if (dictionary.ContainsKey("name"))     //ChartsData
            {
                ChartsData x = new ChartsData();
                x.name = (string)dictionary["name"];
                System.Collections.ArrayList itemss = ((System.Collections.ArrayList)dictionary["name"]);
                foreach (var item in itemss)
                {
                    x.values.Add(serializer.ConvertToType <string>(item));
                }
                return(x);
            }
        }
        return(null);
    }
Пример #15
0
        public TabNewWorld()
        {
            Icon = new Sprite(Ressources.TileIcons, new Point(1, 2));

            var worldNameTextBox = new SingleLineTextBoxWidget(24, "new world", Ressources.FontRomulus)
            {
                Padding = new Margins(8)
            };

            var worldSeedtextBox = new SingleLineTextBoxWidget(24, Rise.Rnd.Next().ToString(), Ressources.FontRomulus)
            {
                Padding = new Margins(8)
            };

            var worldTypeList = new ListWidget()
            {
                UnitBound = new Rectangle(0, 0, 256, 128), AlowUnselecting = false
            };

            foreach (var item in GENERATOR.GENERATORS)
            {
                worldTypeList.AddItem(new ListItemText(item.Key));
            }

            worldTypeList.SelectFirst();

            var generateButton = new Button {
                Text = "Generate", Dock = Dock.Bottom
            }
            .RegisterMouseClickEvent((s) => Game.New(worldNameTextBox.Text.String, worldSeedtextBox.Text.String, GENERATOR.GENERATORS[((ListItemText)worldTypeList.SelectedItem).Text]));

            var worldOptions = new FlowLayout
            {
                Flow      = FlowDirection.TopToBottom,
                Dock      = Dock.Fill,
                Childrens =
                {
                    new Label {
                        Text = "World name:", Padding = new Margins(8), TextAlignement = DrawText.Alignement.Left
                    },
                    worldNameTextBox,
                    new Label {
                        Text = "Seed:", Padding = new Margins(8), TextAlignement = DrawText.Alignement.Left
                    },
                    worldSeedtextBox,
                    new Label {
                        Text = "World type:", Padding = new Margins(8), TextAlignement = DrawText.Alignement.Left
                    },
                    worldTypeList
                }
            };

            Content = new Container()
            {
                Childrens =
                {
                    new Label {
                        Text = "New World", Font = Ressources.FontAlagard, Dock = Dock.Top
                    },
                    generateButton,
                    worldOptions,
                }
            };
        }