protected override void OnLoad(EventArgs args)
        {
            if (!Sitecore.Context.ClientPage.IsEvent)
             {
            SetProperties();
            GridPanel gridPanel = new GridPanel();
            Controls.Add(gridPanel);
            gridPanel.Columns = 4;
            GetControlAttributes();

            foreach (string text2 in base.Attributes.Keys)
            {
               gridPanel.Attributes.Add(text2, base.Attributes[text2]);
            }

            gridPanel.Style["margin"] = "0px 0px 4px 0px";
            SetViewStateString("ID", ID);
            Sitecore.Web.UI.HtmlControls.Literal literal = new Sitecore.Web.UI.HtmlControls.Literal("All");
            literal.Class = ("scContentControlMultilistCaption");

            gridPanel.Controls.Add(literal);
            gridPanel.SetExtensibleProperty(literal, "Width", "50%");
            gridPanel.SetExtensibleProperty(literal, "Row.Height", "20px");

            LiteralControl spacer = new LiteralControl(Images.GetSpacer(24, 1));
            gridPanel.Controls.Add(spacer);
            gridPanel.SetExtensibleProperty(spacer, "Width", "24px");

            literal = new Sitecore.Web.UI.HtmlControls.Literal("Selected");
            literal.Class = "scContentControlMultilistCaption";

            gridPanel.Controls.Add(literal);
            gridPanel.SetExtensibleProperty(literal, "Width", "50%");

            spacer = new LiteralControl(Images.GetSpacer(24, 1));
            gridPanel.Controls.Add(spacer);
            gridPanel.SetExtensibleProperty(spacer, "Width", "24px");

            Scrollbox scrollbox = new Scrollbox();
            scrollbox.ID = GetUniqueID("S");

            gridPanel.Controls.Add(scrollbox);
            scrollbox.Style["border"] = "3px window-inset";
            gridPanel.SetExtensibleProperty(scrollbox, "rowspan", "2");

            DataTreeview dataTreeView = new DataTreeview();
            dataTreeView.ID = ID + "_all";
            scrollbox.Controls.Add(dataTreeView);
            dataTreeView.DblClick = ID + ".Add";

            ImageBuilder builderRight = new ImageBuilder();
            builderRight.Src = "Applications/16x16/nav_right_blue.png";
            builderRight.ID = ID + "_right";
            builderRight.Width = 0x10;
            builderRight.Height = 0x10;
            builderRight.Margin = "2";
            builderRight.OnClick = Sitecore.Context.ClientPage.GetClientEvent(ID + ".Add");

            ImageBuilder builderLeft = new ImageBuilder();
            builderLeft.Src = "Applications/16x16/nav_left_blue.png";
            builderLeft.ID = ID + "_left";
            builderLeft.Width = 0x10;
            builderLeft.Height = 0x10;
            builderLeft.Margin = "2";
            builderLeft.OnClick = Sitecore.Context.ClientPage.GetClientEvent(ID + ".Remove");

            LiteralControl literalControl = new LiteralControl(builderRight.ToString() + "<br/>" + builderLeft.ToString());
            gridPanel.Controls.Add(literalControl);
            gridPanel.SetExtensibleProperty(literalControl, "Width", "30");
            gridPanel.SetExtensibleProperty(literalControl, "Align", "center");
            gridPanel.SetExtensibleProperty(literalControl, "VAlign", "top");
            gridPanel.SetExtensibleProperty(literalControl, "rowspan", "2");

            Sitecore.Web.UI.HtmlControls.Listbox listbox = new Listbox();
                listBox = listbox;
            gridPanel.SetExtensibleProperty(listbox, "VAlign", "top");
            gridPanel.SetExtensibleProperty(listbox, "Height", "100%");

            gridPanel.Controls.Add(listbox);
            listbox.ID = ID + "_selected";
            listbox.DblClick = ID + ".Remove";
            listbox.Style["width"] = "100%";
            listbox.Size = "10";
            listbox.Attributes["onchange"] = "javascript:document.getElementById('" + this.ID + "_help').innerHTML=this.selectedIndex>=0?this.options[this.selectedIndex].innerHTML:''";
            listbox.Attributes["class"] = "scContentControlMultilistBox";

            dataTreeView.Disabled = ReadOnly;
            listbox.Disabled = ReadOnly;

            ImageBuilder builderUp = new ImageBuilder();
            builderUp.Src = "Applications/16x16/nav_up_blue.png";
            builderUp.ID = ID + "_up";
            builderUp.Width = 0x10;
            builderUp.Height = 0x10;
            builderUp.Margin = "2px";
            builderUp.OnClick = Sitecore.Context.ClientPage.GetClientEvent(ID + ".Up");

            ImageBuilder builderDown = new ImageBuilder();
            builderDown.Src = "Applications/16x16/nav_down_blue.png";
            builderDown.ID = ID + "_down";
            builderDown.Width = 0x10;
            builderDown.Height = 0x10;
            builderDown.Margin = "2";
            builderDown.OnClick = Sitecore.Context.ClientPage.GetClientEvent(ID + ".Down");

            literalControl = new LiteralControl(builderUp.ToString() + "<br/>" + builderDown.ToString());
            gridPanel.Controls.Add(literalControl);
            gridPanel.SetExtensibleProperty(literalControl, "Width", "30");
            gridPanel.SetExtensibleProperty(literalControl, "Align", "center");
            gridPanel.SetExtensibleProperty(literalControl, "VAlign", "top");
            gridPanel.SetExtensibleProperty(literalControl, "rowspan", "2");
            gridPanel.Controls.Add(new LiteralControl("<div style=\"border:1px solid #999999;font:8pt tahoma;padding:2px;margin:4px 0px 4px 0px;height:14px\" id=\"" + this.ID + "_help\"></div>"));

            DataContext treeContext = new DataContext();
            gridPanel.Controls.Add(treeContext);
            treeContext.ID = GetUniqueID("D");
            treeContext.Filter = FormTemplateFilterForDisplay();
            dataTreeView.DataContext = treeContext.ID;
            treeContext.DataViewName = "Master";
            if (!string.IsNullOrEmpty(this.SourceDatabaseName))
            {
               treeContext.Parameters = "databasename=" + this.SourceDatabaseName;
            }
            treeContext.Root = DataSource;
            dataTreeView.EnableEvents();

            listbox.Size = "10";
            gridPanel.Fixed = true;
            dataTreeView.AutoUpdateDataContext = true;
            dataTreeView.ShowRoot = true;
            listbox.Attributes["class"] = "scContentControlMultilistBox";

            gridPanel.SetExtensibleProperty(scrollbox, "Height", "100%");
            RestoreState();
             }
             base.OnLoad(args);
        }
 bool IsDeniedMultipleSelection(Item item, Listbox listbox)
 {
     if(item == null)
      {
     return true;
      }
      if(AllowMultipleSelection)
      {
     return false;
      }
      foreach(Sitecore.Web.UI.HtmlControls.ListItem li in listbox.Controls)
      {
         string[] pair = li.Value.Split(new char[]{'|'});
         if(pair.Length < 2) continue;
     if(pair[1] == item.ID.ToString())
     {
        return true;
     }
      }
      return false;
 }
		// This method is the only method that differs from Sitecore's
		// TreeList class
		protected override void OnLoad(EventArgs args)
		{
			Assert.ArgumentNotNull(args, "args");
			if (!Sitecore.Context.ClientPage.IsEvent)
			{
				Database contentDatabase = Sitecore.Context.ContentDatabase;
				if (!string.IsNullOrEmpty(this.DatabaseName))
				{
					contentDatabase = Factory.GetDatabase(this.DatabaseName);
				}

				this.SetProperties();
				GridPanel child = new GridPanel();
				this.Controls.Add(child);
				child.Columns = 4;
				this.GetControlAttributes();
				foreach (string str in base.Attributes.Keys)
				{
					child.Attributes.Add(str, base.Attributes[str]);
				}
				child.Style["margin"] = "0px 0px 4px 0px";
				base.SetViewStateString("ID", this.ID);
				Literal literal = new Literal("All");
				literal.Class = "scContentControlMultilistCaption";
				child.Controls.Add(literal);
				child.SetExtensibleProperty(literal, "Width", "50%");
				child.SetExtensibleProperty(literal, "Row.Height", "20px");
				LiteralControl control = new LiteralControl(Images.GetSpacer(0x18, 1));
				child.Controls.Add(control);
				child.SetExtensibleProperty(control, "Width", "24px");
				literal = new Literal("Selected");
				literal.Class = "scContentControlMultilistCaption";
				child.Controls.Add(literal);
				child.SetExtensibleProperty(literal, "Width", "50%");
				control = new LiteralControl(Images.GetSpacer(0x18, 1));
				child.Controls.Add(control);
				child.SetExtensibleProperty(control, "Width", "24px");
				Scrollbox scrollbox = new Scrollbox();
				scrollbox.ID = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("S");
				child.Controls.Add(scrollbox);
				if (!UIUtil.IsIE())
				{
					scrollbox.Padding = "0px";
				}
				scrollbox.Style["border"] = "3px window-inset";
				child.SetExtensibleProperty(scrollbox, "rowspan", "2");
				child.SetExtensibleProperty(scrollbox, "VAlign", "top");
				// Instantiate the MultiTreeview rather than TreeviewEx
				MultiRootTreeview ex = new MultiRootTreeview();
				// Set the ParentItem of the treeview to the current item
				// This allows the treeview to have a 'context' of where 
				// we currently are in the content tree
				Item parentItem = contentDatabase.GetItem(ItemID);
				ex.ParentItem = parentItem;
				ex.ID = this.ID + "_all";
				if (!string.IsNullOrEmpty(AncestorTemplateDatasource))
				{
					Item parent = parentItem;
					while (parent != null && String.Compare(parent.TemplateID.ToString(), AncestorTemplateDatasource, StringComparison.OrdinalIgnoreCase) != 0)
					{
						parent = parent.Parent;
					}
					ex.MultiTrees.Add(2, parent);
				}
				else if (DataSources.Count > 0)
				{
					foreach (KeyValuePair<int, string> kvp in DataSources)
					{
						if (!string.IsNullOrEmpty(kvp.Value))
						{
							if (kvp.Value == ".")
							{
								ex.MultiTrees.Add(kvp.Key, parentItem);
							}
							else if (kvp.Value.StartsWith("."))
							{
								string path = kvp.Value.Replace(".", parentItem.Paths.FullPath);
								ex.MultiTrees.Add(kvp.Key, contentDatabase.GetItem(path));
							}
							else
							{
								ex.MultiTrees.Add(kvp.Key, contentDatabase.GetItem(kvp.Value));
							}
						}
					}
				}
				scrollbox.Controls.Add(ex);
				ex.DblClick = this.ID + ".Add";
				ex.AllowDragging = false;
				ImageBuilder builder = new ImageBuilder();
				builder.Src = "Applications/16x16/nav_right_blue.png";
				builder.ID = this.ID + "_right";
				builder.Width = 0x10;
				builder.Height = 0x10;
				builder.Margin = UIUtil.IsIE() ? "2px" : "2px 0px 2px 2px";
				builder.OnClick = Sitecore.Context.ClientPage.GetClientEvent(this.ID + ".Add");
				ImageBuilder builder2 = new ImageBuilder();
				builder2.Src = "Applications/16x16/nav_left_blue.png";
				builder2.ID = this.ID + "_left";
				builder2.Width = 0x10;
				builder2.Height = 0x10;
				builder2.Margin = UIUtil.IsIE() ? "2px" : "2px 0px 2px 2px";
				builder2.OnClick = Sitecore.Context.ClientPage.GetClientEvent(this.ID + ".Remove");
				LiteralControl control2 = new LiteralControl(builder + "<br/>" + builder2);
				child.Controls.Add(control2);
				child.SetExtensibleProperty(control2, "Width", "30");
				child.SetExtensibleProperty(control2, "Align", "center");
				child.SetExtensibleProperty(control2, "VAlign", "top");
				child.SetExtensibleProperty(control2, "rowspan", "2");
				Listbox listbox = new Listbox();
				child.Controls.Add(listbox);
				child.SetExtensibleProperty(listbox, "VAlign", "top");
				child.SetExtensibleProperty(listbox, "Height", "100%");
				this._listBox = listbox;
				listbox.ID = this.ID + "_selected";
				listbox.DblClick = this.ID + ".Remove";
				listbox.Style["width"] = "100%";
				listbox.Size = "10";
				listbox.Attributes["onchange"] = "javascript:document.getElementById('" + this.ID + "_help').innerHTML=this.selectedIndex>=0?this.options[this.selectedIndex].innerHTML:''";
				listbox.Attributes["class"] = "scContentControlMultilistBox";
				ex.Enabled = !this.ReadOnly;
				listbox.Disabled = this.ReadOnly;
				ImageBuilder builder3 = new ImageBuilder();
				builder3.Src = "Applications/16x16/nav_up_blue.png";
				builder3.ID = this.ID + "_up";
				builder3.Width = 0x10;
				builder3.Height = 0x10;
				builder3.Margin = "2px";
				builder3.OnClick = Sitecore.Context.ClientPage.GetClientEvent(this.ID + ".Up");
				ImageBuilder builder4 = new ImageBuilder();
				builder4.Src = "Applications/16x16/nav_down_blue.png";
				builder4.ID = this.ID + "_down";
				builder4.Width = 0x10;
				builder4.Height = 0x10;
				builder4.Margin = "2px";
				builder4.OnClick = Sitecore.Context.ClientPage.GetClientEvent(this.ID + ".Down");
				control2 = new LiteralControl(builder3 + "<br/>" + builder4);
				child.Controls.Add(control2);
				child.SetExtensibleProperty(control2, "Width", "30");
				child.SetExtensibleProperty(control2, "Align", "center");
				child.SetExtensibleProperty(control2, "VAlign", "top");
				child.SetExtensibleProperty(control2, "rowspan", "2");
				child.Controls.Add(new LiteralControl("<div style=\"border:1px solid #999999;font:8pt tahoma;padding:2px;margin:4px 0px 4px 0px;height:14px\" id=\"" + this.ID + "_help\"></div>"));
				DataContext context = new DataContext();
				child.Controls.Add(context);
				context.ID = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("D");
				context.Filter = this.FormTemplateFilterForDisplay();
				ex.DataContext = context.ID;
				context.DataViewName = "Master";
				if (!string.IsNullOrEmpty(this.DatabaseName))
				{
					context.Parameters = "databasename=" + this.DatabaseName;
				}
				context.Root = this.DataSource;
				child.Fixed = true;
				ex.ShowRoot = true;
				child.SetExtensibleProperty(scrollbox, "Height", "100%");
				this.RestoreState();
			}
			base.OnLoad(args);
		}
        public ResourcePacksOptionControl(ScreenComponent manager)
            : base(manager)
        {
            Grid grid = new Grid(manager)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
                Margin = Border.All(15),
            };
            Controls.Add(grid);

            grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 });
            grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 100 });
            grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 });
            grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 });
            grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 });
            grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 });

            StackPanel buttons = new StackPanel(manager)
            {
                VerticalAlignment = VerticalAlignment.Stretch,
            };
            grid.AddControl(buttons, 1, 0);

            #region Manipulationsbuttons

            addButton = Button.TextButton(manager, "Add");
            addButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            addButton.Visible = false;
            buttons.Controls.Add(addButton);

            removeButton = Button.TextButton(manager, "Remove");
            removeButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            removeButton.Visible = false;
            buttons.Controls.Add(removeButton);

            moveUpButton = Button.TextButton(manager, "Up");
            moveUpButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            moveUpButton.Visible = false;
            buttons.Controls.Add(moveUpButton);

            moveDownButton = Button.TextButton(manager, "Down");
            moveDownButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            moveDownButton.Visible = false;
            buttons.Controls.Add(moveDownButton);

            #endregion

            applyButton = Button.TextButton(manager, "Apply");
            applyButton.HorizontalAlignment = HorizontalAlignment.Right;
            applyButton.VerticalAlignment = VerticalAlignment.Bottom;
            grid.AddControl(applyButton, 0, 2, 3);

            infoLabel = new Label(ScreenManager)
            {
                HorizontalTextAlignment = HorizontalAlignment.Left,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Top,
                WordWrap = true,
            };
            grid.AddControl(infoLabel, 0, 1, 3);

            #region Listen

            loadedPacksList = new Listbox<ResourcePack>(manager)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
                SelectedItemBrush = new BorderBrush(Color.SaddleBrown * 0.7f),
                TemplateGenerator = ListTemplateGenerator,
            };

            grid.AddControl(loadedPacksList, 0, 0);

            activePacksList = new Listbox<ResourcePack>(manager)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
                SelectedItemBrush = new BorderBrush(Color.SaddleBrown * 0.7f),
                TemplateGenerator = ListTemplateGenerator,
            };

            grid.AddControl(activePacksList, 2, 0);

            #endregion

            #region Info Grid

            //Grid infoGrid = new Grid(ScreenManager)
            //{
            //    HorizontalAlignment = HorizontalAlignment.Stretch,
            //};

            //infoGrid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Auto, Width = 1 });
            //infoGrid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 });
            //infoGrid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 });
            //infoGrid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 });
            //infoGrid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 });

            //Label nameLabel = new Label(ScreenManager)
            //{
            //    Text = "Name:",
            //};
            //infoGrid.AddControl(nameLabel, 0, 0);

            //Label authorLabel = new Label(ScreenManager)
            //{
            //    Text = "Author:",
            //};
            //infoGrid.AddControl(authorLabel, 0, 1);

            //Label descriptionLabel = new Label(ScreenManager)
            //{
            //    Text = "Description:",
            //};
            //infoGrid.AddControl(descriptionLabel, 0, 2);

            //grid.AddControl(infoGrid, 0, 1, 3);

            #endregion

            loadedPacksList.SelectedItemChanged += loadedList_SelectedItemChanged;
            activePacksList.SelectedItemChanged += activeList_SelectedItemChanged;

            addButton.LeftMouseClick += (s, e) =>
            {
                ResourcePack pack = loadedPacksList.SelectedItem;
                loadedPacksList.Items.Remove(pack);
                activePacksList.Items.Add(pack);
                activePacksList.SelectedItem = pack;
            };

            removeButton.LeftMouseClick += (s, e) =>
            {
                ResourcePack pack = activePacksList.SelectedItem;
                activePacksList.Items.Remove(pack);
                loadedPacksList.Items.Add(pack);
                loadedPacksList.SelectedItem = pack;
            };

            moveUpButton.LeftMouseClick += (s, e) =>
            {
                ResourcePack pack = activePacksList.SelectedItem;
                if (pack == null)
                    return;

                int index = activePacksList.Items.IndexOf(pack);
                if (index > 0)
                {
                    activePacksList.Items.Remove(pack);
                    activePacksList.Items.Insert(index - 1, pack);
                    activePacksList.SelectedItem = pack;
                }
            };

            moveDownButton.LeftMouseClick += (s, e) =>
            {
                ResourcePack pack = activePacksList.SelectedItem;
                if (pack == null) return;

                int index = activePacksList.Items.IndexOf(pack);
                if (index < activePacksList.Items.Count - 1)
                {
                    activePacksList.Items.Remove(pack);
                    activePacksList.Items.Insert(index + 1, pack);
                    activePacksList.SelectedItem = pack;
                }
            };

            applyButton.LeftMouseClick += (s, e) =>
            {
                manager.Game.Assets.ApplyResourcePacks(activePacksList.Items);
                Program.Restart();
            };

            // Daten laden

            AssetComponent assets = manager.Game.Assets;
            foreach (var item in assets.LoadedResourcePacks)
                loadedPacksList.Items.Add(item);

            foreach (var item in manager.Game.Assets.ActiveResourcePacks)
            {
                activePacksList.Items.Add(item);
                if (loadedPacksList.Items.Contains(item))
                    loadedPacksList.Items.Remove(item);
            }
        }
		private bool IsDeniedMultipleSelection(Item item, Listbox listbox)
		{
			Assert.ArgumentNotNull(listbox, "listbox");
			if (item == null)
			{
				return true;
			}
			if (!this.AllowMultipleSelection)
			{
				foreach (ListItem item2 in listbox.Controls)
				{
					string[] strArray = item2.Value.Split(new char[] { '|' });
					if ((strArray.Length >= 2) && (strArray[1] == item.ID.ToString()))
					{
						return true;
					}
				}
			}
			return false;
		}
示例#6
0
        public SplitScreen(BaseScreenComponent manager)
            : base(manager)
        {
            Background = new BorderBrush(Color.Gray);                       //Hintergrundfarbe festlegen

            Button backButton = Button.TextButton(manager, "Back");             //Neuen TextButton erzeugen
            backButton.HorizontalAlignment = HorizontalAlignment.Left;          //Links
            backButton.VerticalAlignment = VerticalAlignment.Top;               //Oben
            backButton.LeftMouseClick += (s, e) => { manager.NavigateBack(); }; //KlickEvent festlegen
            Controls.Add(backButton);                                           //Button zum Screen hinzufügen

            //ScrollContainer
            ScrollContainer scrollContainer = new ScrollContainer(manager)  //Neuen ScrollContainer erzeugen
            {
                VerticalAlignment = VerticalAlignment.Stretch,              // 100% Höhe
                HorizontalAlignment = HorizontalAlignment.Stretch           //100% Breite
            };
            Controls.Add(scrollContainer);                                  //ScrollContainer zum Root(Screen) hinzufügen

            //Stackpanel - SubControls werden Horizontal oder Vertikal gestackt
            StackPanel panel = new StackPanel(manager);                 //Neues Stackpanel erzeugen
            panel.VerticalAlignment = VerticalAlignment.Stretch;        //100% Höhe
            scrollContainer.Content = panel;                            //Ein Scroll Container kann nur ein Control beherbergen

            //Label
            Label label = new Label(manager) { Text = "Control Showcase" }; //Neues Label erzeugen
            panel.Controls.Add(label);                                      //Label zu Panel hinzufügen

            Button tB = Button.TextButton(manager, "TEST");
            tB.Background = new TextureBrush(LoadTexture2DFromFile("./test_texture_round.png", manager.GraphicsDevice), TextureBrushMode.Stretch);
            panel.Controls.Add(tB);

            //Button
            Button button = Button.TextButton(manager, "Dummy Button"); //Neuen TextButton erzeugen
            panel.Controls.Add(button);                                 //Button zu Panel hinzufügen

            //Progressbar
            ProgressBar pr = new ProgressBar(manager)                   //Neue ProgressBar erzeugen
            {
                Value = 99,                                             //Aktueller Wert
                Height = 20,                                            //Höhe
                Width = 200                                             //Breite
            };
            panel.Controls.Add(pr);                                     //ProgressBar zu Panel hinzufügen

            //ListBox
            Listbox<string> list = new Listbox<string>(manager);        //Neue ListBox erstellen
            list.TemplateGenerator = (item) =>                          //Template Generator festlegen
            {
                return new Label(manager) { Text = item };              //Control (Label) erstellen
            };
            panel.Controls.Add(list);                                   //Liste zu Panel hinzufügen

            list.Items.Add("Hallo");                                    //Items zur Liste hinzufügen
            list.Items.Add("Welt");                                     //...

            //Combobox
            Combobox<string> combobox = new Combobox<string>(manager)   //Neue Combobox erstellen
            {
                Height = 20,                                            //Höhe 20
                Width = 100                                             //Breite 100
            };
            combobox.TemplateGenerator = (item) =>                      //Template Generator festlegen
            {
                return new Label(manager) { Text = item };              //Control (Label) erstellen
            };
            panel.Controls.Add(combobox);                               //Combobox zu Panel  hinzufügen

            combobox.Items.Add("Combobox");                             //Items zu Combobox hinzufügen
            combobox.Items.Add("Item");
            combobox.Items.Add("Hallo");

            Button clearCombobox = Button.TextButton(manager, "Clear Combobox");
            clearCombobox.LeftMouseClick += (s, e) => {
                combobox.Items.Clear();
                list.Items.Clear();
            };
            panel.Controls.Add(clearCombobox);

            //Slider Value Label
            Label labelSliderHorizontal = new Label(manager);

            //Horizontaler Slider
            Slider sliderHorizontal = new Slider(manager)
            {
                Width = 150,
                Height = 20,
            };
            sliderHorizontal.ValueChanged += (value) => { labelSliderHorizontal.Text = "Value: " + value; }; //Event on Value Changed
            panel.Controls.Add(sliderHorizontal);
            labelSliderHorizontal.Text = "Value: " + sliderHorizontal.Value;                                 //Set Text initially
            panel.Controls.Add(labelSliderHorizontal);

            //Slider Value Label
            Label labelSliderVertical = new Label(manager);

            //Vertikaler Slider
            Slider sliderVertical = new Slider(manager)
            {
                Range = 100,
                Height = 200,
                Width = 20,
                Orientation = Orientation.Vertical
            };
            sliderVertical.ValueChanged += (value) => { labelSliderVertical.Text = "Value: " + value; };
            panel.Controls.Add(sliderVertical);
            labelSliderVertical.Text = "Value: " + sliderVertical.Value;
            panel.Controls.Add(labelSliderVertical);

            Checkbox checkbox = new Checkbox(manager);
            panel.Controls.Add(checkbox);

            //Textbox
            textbox = new Textbox(manager)                      //Neue TextBox erzeugen
            {
                Background = new BorderBrush(Color.LightGray),          //Festlegen eines Backgrounds für ein Control
                HorizontalAlignment = HorizontalAlignment.Stretch,          //100% Breite
                Text = "TEXTBOX!",                                      //Voreingestellter text
                MinWidth = 100                                          //Eine Textbox kann ihre Größe automatisch anpassen
            };

            Button clearTextbox = Button.TextButton(manager, "Clear Textbox");
            clearTextbox.LeftMouseClick += (s, e) =>
            {
                textbox.SelectionStart = 0;
                textbox.Text = "";
            };

            Button disableControls = Button.TextButton(manager, "Toggle Controls disabled");
            disableControls.LeftMouseClick += (s, e) =>
            {
                foreach (var c in panel.Controls)
                {
                    c.Enabled = !c.Enabled;
                }
            };
            panel.Controls.Add(clearTextbox);
            panel.Controls.Add(textbox);                                //Textbox zu Panel hinzufügen
            panel.Controls.Add(disableControls);
        }
示例#7
0
        public LoadScreen(ScreenComponent manager)
            : base(manager)
        {
            Manager = manager;

            Padding = new Border(0, 0, 0, 0);

            Title = Languages.OctoClient.SelectUniverse;

            SetDefaultBackground();

            //Main Panel
            mainStack = new Grid(manager);
            mainStack.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 3 });
            mainStack.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 });
            mainStack.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 });
            mainStack.Margin = Border.All(50);
            mainStack.HorizontalAlignment = HorizontalAlignment.Stretch;
            mainStack.VerticalAlignment = VerticalAlignment.Stretch;

            Controls.Add(mainStack);

            //Level Stack
            levelList = new Listbox<IUniverse>(manager);
            levelList.Background = new BorderBrush(Color.White * 0.5f);
            levelList.VerticalAlignment = VerticalAlignment.Stretch;
            levelList.HorizontalAlignment = HorizontalAlignment.Stretch;
            levelList.Margin = Border.All(10);
            levelList.SelectedItemBrush = new BorderBrush(Color.SaddleBrown * 0.7f);
            levelList.TemplateGenerator += (x) =>
            {
                return new Label(manager)
                {
                    Text = string.Format("{0} ({1})", x.Name, x.Seed),
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Padding = Border.All(10),
                };
            };
            mainStack.AddControl(levelList, 0, 0);

            //Sidebar
            Panel sidebar = new Panel(manager);
            sidebar.Padding = Border.All(20);
            sidebar.VerticalAlignment = VerticalAlignment.Stretch;
            sidebar.HorizontalAlignment = HorizontalAlignment.Stretch;
            sidebar.Background = new BorderBrush(Color.White * 0.5f);
            sidebar.Margin = Border.All(10);
            mainStack.AddControl(sidebar, 1, 0);

            //Universe Info
            Label l = new Label(manager);
            l.Text = " Placeholder ";
            l.VerticalAlignment = VerticalAlignment.Top;
            l.HorizontalAlignment = HorizontalAlignment.Left;
            sidebar.Controls.Add(l);

            //Buttons
            StackPanel buttonStack = new StackPanel(manager);
            buttonStack.VerticalAlignment = VerticalAlignment.Bottom;
            buttonStack.HorizontalAlignment = HorizontalAlignment.Stretch;
            sidebar.Controls.Add(buttonStack);

            //renameButton = getButton("Rename");
            //buttonStack.Controls.Add(renameButton);

            deleteButton = GetButton(Languages.OctoClient.Delete);
            buttonStack.Controls.Add(deleteButton);
            deleteButton.LeftMouseClick += (s, e) =>
            {
                if (levelList.SelectedItem == null)
                {
                    MessageScreen msg = new MessageScreen(manager, Languages.OctoClient.Error, Languages.OctoClient.SelectUniverseFirst);
                    manager.NavigateToScreen(msg);

                    return;
                }

                // Sicherstellen, dass universe nicht geladen ist
                if (ResourceManager.Instance.CurrentUniverse != null &&
                    ResourceManager.Instance.CurrentUniverse.Id == levelList.SelectedItem.Id)
                    return;

                ResourceManager.Instance.DeleteUniverse(levelList.SelectedItem.Id);
                levelList.Items.Remove(levelList.SelectedItem);
                levelList.SelectedItem = null;
                levelList.InvalidateDimensions();
                SettingsManager.Set("LastUniverse", "");
            };

            createButton = GetButton(Languages.OctoClient.Create);
            createButton.LeftMouseClick += (s, e) => manager.NavigateToScreen(new CreateUniverseScreen(manager));
            buttonStack.Controls.Add(createButton);

            playButton = GetButton(Languages.OctoClient.Play);
            playButton.LeftMouseClick += (s, e) =>
            {
                if (levelList.SelectedItem == null)
                {
                    MessageScreen msg = new MessageScreen(manager, Languages.OctoClient.Error, Languages.OctoClient.SelectUniverseFirst);
                    manager.NavigateToScreen(msg);

                    return;
                }

                Play();
            };
            buttonStack.Controls.Add(playButton);

            foreach (var universe in ResourceManager.Instance.ListUniverses())
                levelList.Items.Add(universe);

            // Erstes Element auswählen, oder falls vorhanden das letzte gespielte Universum
            if (levelList.Items.Count >= 1)
                levelList.SelectedItem = levelList.Items[0];

            if (SettingsManager.KeyExists("LastUniverse") && SettingsManager.Get("LastUniverse") != null
                && SettingsManager.Get("LastUniverse") != "")
            {
                levelList.SelectedItem = levelList.Items.First(u => u.Id == Guid.Parse(SettingsManager.Get("LastUniverse")));
            }
        }
示例#8
0
        public LoadScreen(ScreenComponent manager)
            : base(manager)
        {
            Manager = manager;

            Padding = new Border(0, 0, 0, 0);

            SetDefaultBackground();

            //Main Panel
            mainStack = new Grid(manager);
            mainStack.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 3 });
            mainStack.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 });
            mainStack.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 });
            mainStack.Margin = Border.All(50);
            mainStack.HorizontalAlignment = HorizontalAlignment.Stretch;
            mainStack.VerticalAlignment = VerticalAlignment.Stretch;

            Controls.Add(mainStack);

            //Level Stack
            Listbox<IUniverse> levelList = new Listbox<IUniverse>(manager);
            levelList.Background = new BorderBrush(Color.White * 0.5f);
            levelList.VerticalAlignment = VerticalAlignment.Stretch;
            levelList.HorizontalAlignment = HorizontalAlignment.Stretch;
            levelList.Margin = Border.All(10);
            levelList.TemplateGenerator += (x) =>
            {
                return new Label(manager)
                {
                    Text = string.Format("{0} ({1})", x.Name, x.Seed),
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Padding = Border.All(10),
                };
            };
            levelList.SelectedItemChanged += (s, e) =>
            {
                playButton.Enabled = e.NewItem != null;
                deleteButton.Enabled = e.NewItem != null;
            };
            mainStack.AddControl(levelList, 0, 0);

            //Sidebar
            Panel sidebar = new Panel(manager);
            sidebar.Padding = Border.All(20);
            sidebar.VerticalAlignment = VerticalAlignment.Stretch;
            sidebar.HorizontalAlignment = HorizontalAlignment.Stretch;
            sidebar.Background = new BorderBrush(Color.White * 0.5f);
            sidebar.Margin = Border.All(10);
            mainStack.AddControl(sidebar, 1, 0);

            //Universe Info
            Label l = new Label(manager);
            l.Text = " Placeholder ";
            l.VerticalAlignment = VerticalAlignment.Top;
            l.HorizontalAlignment = HorizontalAlignment.Left;
            sidebar.Controls.Add(l);

            //Buttons
            StackPanel buttonStack = new StackPanel(manager);
            buttonStack.VerticalAlignment = VerticalAlignment.Bottom;
            buttonStack.HorizontalAlignment = HorizontalAlignment.Stretch;
            sidebar.Controls.Add(buttonStack);

            //renameButton = getButton("Rename");
            //buttonStack.Controls.Add(renameButton);

            deleteButton = getButton("Delete");
            buttonStack.Controls.Add(deleteButton);
            deleteButton.LeftMouseClick += (s, e) =>
            {
                if (levelList.SelectedItem == null)
                    return;

                // Sicherstellen, dass universe nicht geladen ist
                if (ResourceManager.Instance.CurrentUniverse != null &&
                    ResourceManager.Instance.CurrentUniverse.Id == levelList.SelectedItem.Id)
                    return;

                ResourceManager.Instance.DeleteUniverse(levelList.SelectedItem.Id);
                levelList.Items.Remove(levelList.SelectedItem);
                levelList.SelectedItem = null;
                levelList.InvalidateDimensions();
            };

            createButton = getButton("Create");
            createButton.LeftMouseClick += (s, e) => manager.NavigateToScreen(new CreateUniverseScreen(manager));
            buttonStack.Controls.Add(createButton);

            playButton = getButton("Play");
            playButton.LeftMouseClick += (s, e) =>
            {
                if (levelList.SelectedItem == null)
                    return;

                manager.Player.RemovePlayer();
                manager.Game.Simulation.LoadGame(levelList.SelectedItem.Id);
                manager.Game.Player.InsertPlayer();
                manager.NavigateToScreen(new GameScreen(manager));
            };
            buttonStack.Controls.Add(playButton);

            foreach (var universe in ResourceManager.Instance.ListUniverses())
                levelList.Items.Add(universe);
        }
示例#9
0
        private void ZombieTwitForm()
        {
            var tweets = new[]{
                                    @"@zombieHunter Zombies are coming!"
                                    , @"@zombieHunter Zombies are getting closer!"
                                    , @"@zombieHunter THEY'RE HERE!!!"
                                    , @"@zombieHunter Send the Gadgets!!!"
                                    , @"@zombieHunter Tell my wife and kids..."
                                    , @"@zombieHunter ...I'll eat them later!"
                                };

            var frm = new Form("zombie twit");

            // Add panel
            var pnl = new Skewworks.Tinkr.Controls.Panel("pnl1", 0, 0, 800, 480);
            pnl.BackgroundImage = Resources.GetBitmap(Resources.BitmapResources.Zombies);
            frm.AddControl(pnl);

            // Add the app bar.
            pnl.AddControl(BuildAppBar(frm.Name));

            // Add a title.
            var title = new Label("lblTitle", "Zombie Twit", _fntHuge, frm.Width / 2 - 100, 50) { Color = Gadgeteer.Color.Yellow };
            pnl.AddControl(title);

            // Add a listbox
            var lb = new Listbox("lb1", _fntArialBold11, frm.Width / 2 - 200, frm.Height / 2 - 100, 400, 200, null);
            pnl.AddControl(lb);

            TinkrCore.ActiveContainer = frm;

            byte lastTweet = 0;
            var timer = new GT.Timer(2000);
            timer.Tick += timer1 =>
                              {
                                  if(lastTweet >= tweets.Length)
                                  {
                                      timer.Stop();
                                      return;
                                  }
                                  //lb.InsertAt(tweets[lastTweet++], 1);
                                  lb.AddItem(tweets[lastTweet++]);
                              };
            timer.Start();
        }