public override bool Interact(Level level, int xt, int yt, Player player, Item item, int attackDir) { var toolItem = item as ToolItem; if (toolItem == null) { return(false); } ToolItem tool = toolItem; if (tool.ObjectType == ToolType.Shovel && player.PayStamina(4 - tool.Level)) { level.SetTile(xt, yt, Hole, 0); level.Add(new ItemEntity(new ResourceItem(Resource.Dirt), xt * 16 + Random.NextInt(10) + 3, yt * 16 + Random.NextInt(10) + 3)); GameEffectManager.Play("monsterhurt"); return(true); } if (tool.ObjectType != ToolType.Hoe || !player.PayStamina(4 - tool.Level)) { return(false); } level.SetTile(xt, yt, Farmland, 0); GameEffectManager.Play("monsterhurt"); return(true); }
void DhtChanged(object sender, ExtensionNodeEventArgs e) { try { TorrentController controller = ServiceManager.Get <TorrentController> (); if (e.Change == ExtensionChange.Add) { TypeExtensionNode node = (TypeExtensionNode)e.ExtensionNode; IDhtExtension dht = (IDhtExtension)node.GetInstance(); if (dht.State == MonoTorrent.DhtState.NotReady) { dht.Start(); } controller.Engine.RegisterDht(dht); ToolItem w = dht.GetWidget(); if (w != null) { mainWindow.StatusToolbar.Insert(new SeparatorToolItem { Draw = false, WidthRequest = 10 }, 0); mainWindow.StatusToolbar.Insert(w, 0); mainWindow.StatusToolbar.ShowAll(); } logger.Info("DHT has been enabled"); } else { logger.Warn("DHT cannot be disabled on the fly"); } } catch (Exception ex) { logger.Error("Failed to enable DHT: {0}", ex.Message); } }
/// <summary> /// Populate the main menu tool strip. /// We rebuild the contents from scratch /// </summary> /// <param name="menuDescriptions">Menu descriptions for each menu item.</param> public void PopulateMainToolStrip(List <MenuDescriptionArgs> menuDescriptions) { foreach (Widget child in toolStrip.Children) { toolStrip.Remove(child); } foreach (MenuDescriptionArgs description in menuDescriptions) { Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(null, description.ResourceNameForImage, 20, 20); ToolButton button = new ToolButton(new Gtk.Image(pixbuf), description.Name); button.Homogeneous = false; button.LabelWidget = new Label(description.Name); Pango.FontDescription font = new Pango.FontDescription(); font.Size = (int)(8 * Pango.Scale.PangoScale); button.LabelWidget.ModifyFont(font); if (description.OnClick != null) { button.Clicked += description.OnClick; } toolStrip.Add(button); } ToolItem item = new ToolItem(); item.Expand = true; toolbarlabel = new Label(); toolbarlabel.Xalign = 1.0F; toolbarlabel.Xpad = 10; toolbarlabel.ModifyFg(StateType.Normal, new Gdk.Color(0x99, 0x99, 0x99)); item.Add(toolbarlabel); toolbarlabel.Visible = false; toolStrip.Add(item); toolStrip.ShowAll(); }
protected void Page_Load(object sender, EventArgs e) { ToolItem tool = new ToolItem(Sitecore.Context.Item); if (tool != null) { string toolControl = tool.GetToolType(); if (!String.IsNullOrEmpty(toolControl)) { try { Control cntrl = this.Page.LoadControl(toolControl); ToolPh.Controls.Add(cntrl); } catch (Exception ex) { Log.Error(String.Format( "Could not load tool type {0}, check thay the correct tool is defined within /sitecore/content/Components/Your Health/Tool Types, error: {1}" ,toolControl , ex.Message ), this); mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex); } } } this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script> $(function(){ $.va_init.functions.setupTools(); }); </script>")); }
public Form1(string name, string path) { InitializeComponent(); _name = name; _path = path; tool = new ToolItem(); }
/// <summary> /// Initializes an inventory UI item. /// </summary> /// <param name="itemData">Item data to initialize the UI with.</param> public void InitializeWithData(ToolItem itemData) { item = itemData; // set the ui's sprite. GetComponent <Image>().sprite = AssetManager.Instance.GetSpriteFromManifest(itemData.SpriteName); }
public void DropToolItem(ToolItem item) { GameObject instit = Instantiate(item.DropPrefab, transform.position + Vector3.forward, transform.rotation); instit.GetComponent <ToolItem>().Quantity = item.Quantity; instit.GetComponent <ToolItem>().Tool = item.Tool; }
// Left click to withdraw public InteractResult OnActLeft(InteractionContext context) { // Some tools can't pull from containers. if (context.SelectedItem != null) { var canPull = ItemAttribute.Get <PullFromChest>(context.SelectedItem.Type)?.CanPull ?? true; if (!canPull) { return(InteractResult.NoOp); } } ToolItem selectedTool = context.SelectedItem as ToolItem; ValResult <int> result = this.Inventory.MoveAsManyItemsAsPossible(context.Player.User.Inventory.Carried, itemStack => { var requiresTool = ItemAttribute.Get <RequiresToolAttribute>(itemStack.Item.Type); return(requiresTool?.IsValidTool(context.SelectedItem?.Type) ?? true); }, context.Player.User); if (result.Success) { if (result.Val > 0) { return(InteractResult.Success); } else { return(InteractResult.NoOp); } } else { return(InteractResult.Failure(result.Message)); } }
/// <summary> /// Sets up the DashPatternBox in the Toolbar. /// /// Note that the dash pattern change event response code must be created manually outside of the DashPatternBox /// (using the returned Gtk.ComboBox from the SetupToolbar method) so that each tool that uses it /// can react to the change in pattern according to its usage. /// /// Returns null if the DashPatternBox has already been setup; otherwise, returns the DashPatternBox itself. /// </summary> /// <param name="tb">The Toolbar to add the DashPatternBox to.</param> /// <returns>null if the DashPatternBox has already been setup; otherwise, returns the DashPatternBox itself.</returns> public Gtk.ComboBox SetupToolbar(Toolbar tb) { if (dashPatternSep == null) { dashPatternSep = new SeparatorToolItem(); } tb.AppendItem(dashPatternSep); if (dashPatternLabel == null) { dashPatternLabel = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Dash"))); } tb.AppendItem(dashPatternLabel); if (comboBox == null) { comboBox = new ToolBarComboBox(100, 0, true, "-", " -", " --", " ---", " -", " -", " - --", " - - --------", " - - ---- - ----"); } tb.AppendItem(comboBox); if (dashChangeSetup) { return(null); } else { dashChangeSetup = true; return(comboBox.ComboBox); } }
protected void SetUp(string param) { _shims = ShimsContext.Create(); var toolItem = new ToolItem(imageDir, imageDir); var toolItemCollection = new ToolItemCollection(); toolItemCollection.Insert(0, toolItem); ShimToolBase.AllInstances.BackImageGet = (x) => image; if (param.Equals(negativeIndex)) { ShimToolDropDownList.AllInstances.SelectedIndexGet = (x) => - 1; ShimToolDropDownList.AllInstances.TextGet = (x) => imageDir; ShimWebControl.AllInstances.WidthGet = (x) => new Unit(value); ShimToolBase.AllInstances.DropDownImageGet = (x) => image; } else if (param.Equals(indexText)) { ShimToolDropDownList.AllInstances.SelectedIndexGet = (x) => 0; ShimToolDropDownList.AllInstances.ChangeToSelectedTextGet = (x) => SelectedText.Text; ShimToolBase.AllInstances.ItemsGet = (x) => toolItemCollection; ShimWebControl.AllInstances.WidthGet = (x) => Unit.Empty; ShimToolBase.AllInstances.DropDownImageGet = (x) => image; } else if (param.Equals(indexValue)) { ShimToolDropDownList.AllInstances.SelectedIndexGet = (x) => 0; ShimToolDropDownList.AllInstances.ChangeToSelectedTextGet = (x) => SelectedText.Value; ShimToolBase.AllInstances.ItemsGet = (x) => toolItemCollection; ShimWebControl.AllInstances.WidthGet = (x) => Unit.Empty; ShimToolBase.AllInstances.DropDownImageGet = (x) => string.Empty; } ShimWebControl.AllInstances.HeightGet = (x) => new Unit(value); ShimWebControl.AllInstances.ForeColorGet = (x) => Color.AliceBlue; }
public void RemoveButton(ToolItem item) { if (item.ControlObject != null) { Control.Remove((Gtk.Widget)item.ControlObject); } }
public GtkToolbar(Window parent, ToolbarModel model) { this.Updating = false; this.ToolbarStyle = ToolbarStyle.Icons; this.Tooltips = false; buttons = new ToolbarItem[model.Count]; for (int i = 0; i < buttons.Length; i++) { buttons[i] = new ToolbarItem(this, model, i); this.Insert(buttons[i], -1); } ToolItem space = new ToolItem(); space.Expand = true; ToolButton info = new ToolButton(Stock.Info); info.Clicked += (sender, args) => { GtkAbout.ShowAbout(parent); }; this.Insert(space, -1); this.Insert(info, -1); model.ToolbarChangedEvent += (sender, e) => SetSelected(e.Value); }
public override bool interact(Level level, int xt, int yt, Player player, Item item, int attackDir) { if (item is ToolItem) { ToolItem tool = (ToolItem)item; if (tool.type == ToolType.shovel) { if (player.payStamina(4 - tool.level)) { level.setTile(xt, yt, Tile.hole, 0); level.add(new ItemEntity(new ResourceItem(Resource.dirt), xt * 16 + random.nextInt(10) + 3, yt * 16 + random.nextInt(10) + 3)); Sound.monsterHurt.play(); return(true); } } if (tool.type == ToolType.hoe) { if (player.payStamina(4 - tool.level)) { level.setTile(xt, yt, Tile.farmland, 0); Sound.monsterHurt.play(); return(true); } } } return(false); }
public ActionResult <ToolItem> PostTodoItem2(ToolItem item) { _context.TodoItems.Add(item); _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetTodoItem), new { id = item.Id }, item)); }
public DocumentWorkView() { actualParam = new QParam(LogicType.And, DocumentWork.DBTable.ParseProperty(nameof(DocumentWork.DateComplete)), CompareType.Is, null); view.ApplySortInternal(new DBComparer <DocumentWork, long?>(DocumentWork.DBTable.PrimaryKey)); view.Query.Parameters.Add(actualParam); list.AllowSort = false; Name = nameof(DocumentWorkView); Text = "Works"; toolActual = new ToolItem(ToolActualClick) { Name = "Actual", Checked = true, CheckOnClick = true, GlyphColor = Colors.Green, Glyph = GlyphType.CheckCircleO }; Bar.Add(toolActual); //list.ListInfo = new LayoutListInfo( // new LayoutColumn() { Name = "ToString", FillWidth = true }, // new LayoutColumn() { Name = "Date", Width = 115 }, // new LayoutColumn() { Name = "IsComplete", Width = 20 }) //{ // ColumnsVisible = false, // HeaderVisible = false //}; }
/// <summary> /// Refreshes the page. /// </summary> /// <param name="e">The event.</param> public void Refresh(Event e) { if (e is RemovedReceipeListEvent) { RemovedReceipeListEvent srcEvnt = (RemovedReceipeListEvent)e; Time time = srcEvnt.Time; List <ItemReceipe> newList = new List <ItemReceipe>(); if (this.Model.ReceipeList.ContainsKey(time.Date)) { Dictionary <string, Receipe> previousList = this.Model.ReceipeList[time.Date].ReceipeTimeOfDay[time.TimeOfDay].Receipes; foreach (Receipe receipe in previousList.Values) { newList.Add(ToolItem.CreateItemReceipe(receipe)); } } if (time.TimeOfDay.Equals("Matin")) { morningReceipeViewSource.Source = newList; } else if (time.TimeOfDay.Equals("Midi")) { noonReceipeViewSource.Source = newList; } else if (time.TimeOfDay.Equals("Soir")) { evenningReceipeViewSource.Source = newList; } } }
/// <summary> /// Refreshes the specified e. /// </summary> /// <param name="e">The e.</param> public void Refresh(Event e) { if (e is ReceipeEvent) { ReceipeEvent receipeE = (ReceipeEvent)e; Receipe receipe = receipeE.Receipe; if (receipeE is AddedReceipeEvent) { this.ItemsReceipe.Add(ToolItem.CreateItemReceipe(receipe)); } else if (receipeE is RemovedReceipeEvent) { foreach (ItemReceipe item in this.ItemsReceipe) { if (item.Receipe == receipe) { this.ItemsReceipe.Remove(item); } } } else if (receipeE is ClearedReceipeEvent) { this.ItemsReceipe = new List <ItemReceipe>(); } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); Stopwatch sw = new Stopwatch(); sw.Restart(); toolBar2.Suspend(); for (int i = 0; i < 3; i++) { toolBar2.Items.RemoveAt(i); } for (int i = 0; i < 3; i++) { toolBar2.Items.Insert(0, new ToolItem(i.ToString())); } for (int i = 0; i < 900; i++) { ToolItem item = new ToolItem { Text = i.ToString(), Image = Resources.online, EndDesc = "x1", HeadDesc = "16.00", Desc = "+" }; toolBar2.Items.Add(item); } toolBar2.Resume(); sw.Stop(); toolBar2.TStart(); //toolBar1.TClickFirst(); }
protected virtual void InsertProxy(Gtk.Action menuAction, Widget parent, Widget afterItem) { int position = 0; Widget item = null; if (parent is MenuItem || parent is Menu) { Menu parent_menu = ((parent is MenuItem) ? (parent as MenuItem).Submenu : parent) as Menu; position = (afterItem != null) ? Array.IndexOf(parent_menu.Children, afterItem as MenuItem) + 1 : 0; item = GetNewMenuItem(); if (item != null) { parent_menu.Insert(item, position); } } else if (parent is Toolbar) { ToolItem after_item = afterItem as ToolItem; if (after_item != null) { position = (parent as Toolbar).GetItemIndex(after_item); ToolItem tool_item = GetNewToolItem(); if (tool_item != null) { (parent as Toolbar).Insert(tool_item, position); item = tool_item; } } } if (item != null) { action.ConnectProxy(item); } }
private void InitalizeToolbar() { toolBuild = cmdBuild.CreateToolItem(); toolRebuild = cmdRebuild.CreateToolItem(); toolClean = cmdClean.CreateToolItem(); toolCancelBuild = cmdCancelBuild.CreateToolItem(); ToolBar = toolbar = new ToolBar(); ToolBar.Style = "ToolBar"; ToolBar.Items.Add(cmdNew); ToolBar.Items.Add(cmdOpen); ToolBar.Items.Add(cmdSave); ToolBar.Items.Add(new SeparatorToolItem { Type = SeparatorToolItemType.Divider }); ToolBar.Items.Add(cmdUndo); ToolBar.Items.Add(cmdRedo); ToolBar.Items.Add(new SeparatorToolItem { Type = SeparatorToolItemType.Divider }); ToolBar.Items.Add(cmdNewItem); ToolBar.Items.Add(cmdExistingItem); ToolBar.Items.Add(cmdNewFolder); ToolBar.Items.Add(cmdExistingFolder); ToolBar.Items.Add(new SeparatorToolItem { Type = SeparatorToolItemType.Divider }); ToolBar.Items.Add(toolBuild); ToolBar.Items.Add(toolRebuild); ToolBar.Items.Add(toolClean); toolbar.Items.Add(toolCancelBuild); }
public override bool CanHarvest(ToolItem tool) { return(tool is PickaxeItem && (tool.ToolMaterial == ToolMaterial.Iron || tool.ToolMaterial == ToolMaterial.Gold || tool.ToolMaterial == ToolMaterial.Diamond)); }
public void UnfocusTool() { if (resetFocusPosition) { focusItem.UnfocusItem(); focusIndex = activeIndex; focusItem = activeItem; ShiftItems(); } else { focusItem.UnfocusItem(); } foreach (ToolItem item in toolItems) { item.Hide(); } focusItem.Unhide(); focusItem.SetFocus(unfocusPos, inactiveFontSize, false); largeToolPart.SetActive(false); smallToolPart.SetActive(true); }
public void RemoveToolItem(ToolItem item) { if (toolItems.Contains(item)) { toolItems.Remove(item); } }
/// <summary>Populate the main menu tool strip.</summary> /// <param name="menuDescriptions">Descriptions for each item.</param> public void Populate(List <MenuDescriptionArgs> menuDescriptions) { accelerators = new AccelGroup(); foreach (Widget child in toolStrip.Children) { toolStrip.Remove(child); child.Dispose(); } foreach (MenuDescriptionArgs description in menuDescriptions) { Gtk.Image image = null; Gdk.Pixbuf pixbuf = null; ManifestResourceInfo info = Assembly.GetExecutingAssembly().GetManifestResourceInfo(description.ResourceNameForImage); if (info != null) { pixbuf = new Gdk.Pixbuf(null, description.ResourceNameForImage, 20, 20); image = new Gtk.Image(pixbuf); } ToolItem item = new ToolItem(); item.Expand = true; if (description.OnClick == null) { Label toolbarlabel = new Label(); if (description.RightAligned) { toolbarlabel.Xalign = 1.0F; } toolbarlabel.Xpad = 10; toolbarlabel.Text = description.Name; toolbarlabel.TooltipText = description.ToolTip; toolbarlabel.Visible = !String.IsNullOrEmpty(toolbarlabel.Text); item.Add(toolbarlabel); toolStrip.Add(item); toolStrip.ShowAll(); } else { ToolButton button = new ToolButton(image, description.Name); button.Homogeneous = false; button.LabelWidget = new Label(description.Name); button.Clicked += description.OnClick; if (!string.IsNullOrWhiteSpace(description.ShortcutKey)) { Gtk.Accelerator.Parse(description.ShortcutKey, out uint key, out Gdk.ModifierType modifier); button.AddAccelerator("clicked", accelerators, key, modifier, AccelFlags.Visible); } item = button; } toolStrip.Add(item); } Window mainWindow = GetMainWindow(); if (mainWindow != null) { mainWindow.AddAccelGroup(accelerators); } toolStrip.ShowAll(); }
/// <summary> /// Fills the page with the previous elements while the navigation. Any state loaded is given when the page /// is recreated from a previous session. /// </summary> /// <param name="sender">The event source ; generaly <see cref="NavigationHelper" /></param> /// <param name="e">Event data that give the parameter of the navigation transmitted /// <see cref="Frame.Navigate(Type, Object)" /> during the initial request of this page and /// a state dictionnary preserved by this page during a previous session /// The state will not take the value Null when the first visit of this page.</param> private void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { GoToReceipeListEvent evnt = e.NavigationParameter as GoToReceipeListEvent; this.Model = evnt.AppModel; this.time = evnt.Time; List <ItemReceipe> receipes = new List <ItemReceipe>(); if (evnt.ReceipeTime is ReceipeTimeOfDay) { ReceipeTimeOfDay receipeTimeOfDay = (ReceipeTimeOfDay)evnt.ReceipeTime; foreach (Receipe receipe in receipeTimeOfDay.Receipes.Values) { receipes.Add(ToolItem.CreateItemReceipe(receipe)); } HandleTitle(receipeTimeOfDay); } else if (evnt.ReceipeTime is ReceipeDate) { ReceipeDate receipeDate = (ReceipeDate)evnt.ReceipeTime; foreach (ReceipeTimeOfDay receipeTimeOfDay in receipeDate.ReceipeTimeOfDay.Values) { foreach (Receipe receipe in receipeTimeOfDay.Receipes.Values) { receipes.Add(ToolItem.CreateItemReceipe(receipe)); } } HandleTitle(receipeDate); } listReceipeViewSource.Source = receipes; }
public void ChangeToolItemList(List <ToolItem> newItems) { toolItems = newItems; activeIndex = 0; focusIndex = 0; activeItem = toolItems[0]; focusItem = toolItems[0]; }
public override bool GetDrop(ToolItem tool, out ItemStack[] drop) { drop = new[] { new ItemStack(new RedstoneItem(), (sbyte)MathHelper.Random.Next(4, 5)) }; return(tool is PickaxeItem && (tool.ToolMaterial == ToolMaterial.Iron || tool.ToolMaterial == ToolMaterial.Gold || tool.ToolMaterial == ToolMaterial.Diamond)); }
public void AddToolItem(ToolItem item) { ToolItem itemToAdd = ToolList.First(t => t.Tool.GatherType == item.Tool.GatherType); itemToAdd.Quantity = item.Quantity; itemToAdd.Tool = item.Tool; Items.Add(itemToAdd); }
private ToolItem WidgetToTool(MenuItem widget) { var item = new ToolItem(); item.Add((Widget)widget); item.WidthRequest = widget.GetWidth(); return(item); }
public void AddWidget(MenuItem widget, int position) { var item = new ToolItem(); item.Add((Widget)widget); item.WidthRequest = widget.GetWidth(); Insert(item, position); }
private static ToolItem CreateToolItem(XmlNode toolNode) { ToolItem toolItem = new ToolItem(); toolItem.SetBase(GetBaseItem(toolNode)); toolItem.itemType = BaseItem.ItemType.TOOL; return(toolItem); }
void Update () { if (Input.GetMouseButton(0)) { Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); RaycastHit2D hit = Physics2D.Raycast (mousePos, Vector3.zero); if (hit.collider && hit.collider.gameObject.tag == "Draggable") { heldItem = hit.collider.gameObject.GetComponent<ToolItem>(); } if (heldItem != null) { bool intersecting = false; GameObject[] interactables = GameObject.FindGameObjectsWithTag("Interactable"); for (int i = 0; i < interactables.Length; i++) { if (DoObjectsIntersect(heldItem.gameObject, interactables[i])) { intersecting = true; targetItem = interactables[i].GetComponent<TargetItem>(); if (targetItem != null && !targetItem.activated) { heldItem.InteractWith(targetItem); } } } if (intersecting == false) { targetItem = null; } } } else { if (heldItem != null && targetItem != null) { heldItem.AddPoints(); } targetItem = null; heldItem = null; } }
private void addMenuItem_Click(object sender, EventArgs e) { AddItemDialog dialog = new AddItemDialog(); if (dialog.ShowDialog() == DialogResult.OK) { ToolItem toolItem = null; // The selected item was a MenuItem so add it as a ToolStripButton if (dialog.SelectedItem is ToolStripMenuItem) { ToolStripMenuItem item = dialog.SelectedItem as ToolStripMenuItem; ToolStripMenuItem menuItem = (ToolStripMenuItem)item.Tag; // Create ToolBar Button ToolStripButton toolButton = ToolbarHelper.CreateButton(menuItem); // Create ToolItem toolItem = new ToolItem(toolButton, dialog.SelectedMenu); } else { // Otherwise create a ToolItem for the separator dialog.SelectedItem.Name = "-"; toolItem = new ToolItem(dialog.SelectedItem, "-"); } toolItem.Visible = true; // Insert it based on the currently selected item in the tool item list int index = itemList.SelectedIndex < 0 ? itemList.Items.Count : itemList.SelectedIndex + 1; Items.Insert(index, toolItem); itemList.Items.Insert(index, toolItem); itemList.SetItemChecked(index, true); // Select the new item to more easily move it itemList.SelectedIndex = index; ToolbarHelper.ArrangeToolbar(Items); } }
// pridanie menu a toolbarov do prislusnich widgetov private void OnWidgetAdd(object obj, AddWidgetArgs args) { if (args.Widget is Toolbar) { args.Widget.Show(); if (args.Widget.Name == "toolbarLeft") { toolbarLeft = (Toolbar)args.Widget; toolbarLeft.ShowAll(); toolbarLeft.IconSize = IconSize.LargeToolbar; vpMenuLeft.Pack1(toolbarLeft, false, false); } if (args.Widget.Name == "toolbarMiddle") { toolbarMiddle = (Toolbar)args.Widget; vbMenuMidle.PackEnd(toolbarMiddle,true, true, 0);//true, false, ToolItem tic = new ToolItem(); ToolItem tic2 = new ToolItem(); ToolItem tic3 = new ToolItem(); ToolItem til1 = new ToolItem(); ToolItem til2 = new ToolItem(); ToolItem til3 = new ToolItem(); /*Label lbl1 = new Label(MainClass.Languages.Translate("project")); Label lbl2 = new Label(MainClass.Languages.Translate("resolution")); Label lbl3 = new Label(MainClass.Languages.Translate("device"));*/ Label lbl1 = new Label(MainClass.Languages.Translate(" ")); Label lbl2 = new Label(MainClass.Languages.Translate(" ")); Label lbl3 = new Label(MainClass.Languages.Translate(" ")); til1.Add(lbl1); til2.Add(lbl2); til3.Add(lbl3); if(MainClass.Platform.IsMac){ VBox vboxMenu1 = new VBox(); vboxMenu1.PackStart(new Label(),true,false,0); vboxMenu1.PackStart(ddbProject,false,false,0); vboxMenu1.PackEnd(new Label(),true,false,0); VBox vboxMenu2 = new VBox(); vboxMenu2.PackStart(new Label(),true,false,0); vboxMenu2.PackStart(ddbResolution,false,false,0); vboxMenu2.PackEnd(new Label(),true,false,0); VBox vboxMenu3 = new VBox(); vboxMenu3.PackStart(new Label(),true,false,0); vboxMenu3.PackStart(ddbDevice,false,false,0); vboxMenu3.PackEnd(new Label(),true,false,0); tic.Add(vboxMenu1); tic2.Add(vboxMenu2); tic3.Add(vboxMenu3); } else { tic.Add(ddbProject); tic2.Add(ddbResolution); tic3.Add(ddbDevice); } toolbarMiddle.Insert(tic2, 0); toolbarMiddle.Insert(til2, 0); //toolbarMiddle.Insert(new SeparatorToolItem(), 0); toolbarMiddle.Insert(tic3, 0); toolbarMiddle.Insert(til3, 0); //toolbarMiddle.Insert(new SeparatorToolItem(), 0); toolbarMiddle.Insert(tic, 0); toolbarMiddle.Insert(til1, 0); toolbarMiddle.ShowAll(); } if (args.Widget.Name == "toolbarRight1") { toolbarRight1 = (Toolbar)args.Widget; toolbarRight1.IconSize = IconSize.SmallToolbar; toolbarRight1.ToolbarStyle = ToolbarStyle.Icons; //toolbarRight. //hbMenuRight.PackStart(toolbarRight, true, true,0); //vbRight.PackStart(toolbarRight1, true, true,0);//Pack1(toolbarRight, true, true); tblMenuRight.Attach(toolbarRight1,1,2,0,1,AttachOptions.Expand|AttachOptions.Fill,AttachOptions.Fill,0,0); } if (args.Widget.Name == "toolbarRight2") { toolbarRight2 = (Toolbar)args.Widget; toolbarRight2.IconSize = IconSize.SmallToolbar; toolbarRight2.ToolbarStyle = ToolbarStyle.Icons; //toolbarRight2.AccelCanActivate; //toolbarRight. //hbMenuRight.PackStart(toolbarRight, true, true,0); tblMenuRight.Attach(toolbarRight2,1,2,1,2,AttachOptions.Expand|AttachOptions.Fill,AttachOptions.Fill,0,0); //vbRight.PackEnd(toolbarRight2, true, true,0);//Pack1(toolbarRight, true, true); } } if (args.Widget is MenuBar) { mainMenu =(MenuBar)args.Widget; mainMenu.Show(); if(!MainClass.Platform.IsMac) vbMenuMidle.PackStart(mainMenu, true, true, 0); } }
internal void Decorate(ToolItem decItem) { }
private void moveItem(ToolItem item, int newIndex) { _items.Remove(item); _items.Insert(newIndex, item); itemList.Items.Remove(item); itemList.Items.Insert(newIndex, item); itemList.SetItemChecked(newIndex, item.Visible); itemList.SelectedIndex = newIndex; ToolbarHelper.ArrangeToolbar(Items); }
// // Constructor // public MainWindow (Db db) { this.db = db; if (Toplevel == null) Toplevel = this; Glade.XML gui = new Glade.XML (null, "f-spot.glade", "main_window", "f-spot"); gui.Autoconnect (this); LoadPreference (Preferences.MAIN_WINDOW_WIDTH); LoadPreference (Preferences.MAIN_WINDOW_X); LoadPreference (Preferences.MAIN_WINDOW_MAXIMIZED); main_window.ShowAll (); LoadPreference (Preferences.SIDEBAR_POSITION); LoadPreference (Preferences.METADATA_EMBED_IN_IMAGE); LoadPreference (Preferences.COLOR_MANAGEMENT_ENABLED); LoadPreference (Preferences.COLOR_MANAGEMENT_USE_X_PROFILE); FSpot.ColorManagement.LoadSettings(); #if GTK_2_10 pagesetup_menu_item.Activated += HandlePageSetupActivated; #else pagesetup_menu_item.Visible = false; #endif toolbar = new Gtk.Toolbar (); toolbar_vbox.PackStart (toolbar); ToolButton import_button = GtkUtil.ToolButtonFromTheme ("gtk-add", Catalog.GetString ("Import"), false); import_button.Clicked += HandleImportCommand; import_button.SetTooltip (ToolTips, Catalog.GetString ("Import new images"), null); toolbar.Insert (import_button, -1); toolbar.Insert (new SeparatorToolItem (), -1); ToolButton rl_button = GtkUtil.ToolButtonFromTheme ("object-rotate-left", Catalog.GetString ("Rotate Left"), true); rl_button.Clicked += HandleRotate270Command; toolbar.Insert (rl_button, -1); ToolButton rr_button = GtkUtil.ToolButtonFromTheme ("object-rotate-right", Catalog.GetString ("Rotate Right"), true); rr_button.Clicked += HandleRotate90Command; toolbar.Insert (rr_button, -1); toolbar.Insert (new SeparatorToolItem (), -1); browse_button = new ToggleToolButton (); browse_button.Label = Catalog.GetString ("Browse"); browse_button.IconName = "mode-browse"; browse_button.IsImportant = true; browse_button.Toggled += HandleToggleViewBrowse; browse_button.SetTooltip (ToolTips, Catalog.GetString ("Browse many photos simultaneously"), null); toolbar.Insert (browse_button, -1); edit_button = new ToggleToolButton (); edit_button.Label = Catalog.GetString ("Edit Image"); edit_button.IconName = "mode-image-edit"; edit_button.IsImportant = true; edit_button.Toggled += HandleToggleViewPhoto; edit_button.SetTooltip (ToolTips, Catalog.GetString ("View and edit a photo"), null); toolbar.Insert (edit_button, -1); toolbar.Insert (new SeparatorToolItem (), -1); ToolButton fs_button = GtkUtil.ToolButtonFromTheme ("view-fullscreen", Catalog.GetString ("Fullscreen"), true); fs_button.Clicked += HandleViewFullscreen; fs_button.SetTooltip (ToolTips, Catalog.GetString ("View photos fullscreen"), null); toolbar.Insert (fs_button, -1); ToolButton ss_button = GtkUtil.ToolButtonFromTheme ("media-playback-start", Catalog.GetString ("Slideshow"), true); ss_button.Clicked += HandleViewSlideShow; ss_button.SetTooltip (ToolTips, Catalog.GetString ("View photos in a slideshow"), null); toolbar.Insert (ss_button, -1); SeparatorToolItem white_space = new SeparatorToolItem (); white_space.Draw = false; white_space.Expand = true; toolbar.Insert (white_space, -1); ToolItem label_item = new ToolItem (); count_label = new Label (String.Empty); label_item.Child = count_label; toolbar.Insert (label_item, -1); display_previous_button = new ToolButton (Stock.GoBack); toolbar.Insert (display_previous_button, -1); display_previous_button.SetTooltip (ToolTips, Catalog.GetString ("Previous photo"), String.Empty); display_previous_button.Clicked += new EventHandler (HandleDisplayPreviousButtonClicked); display_next_button = new ToolButton (Stock.GoForward); toolbar.Insert (display_next_button, -1); display_next_button.SetTooltip (ToolTips, Catalog.GetString ("Next photo"), String.Empty); display_next_button.Clicked += new EventHandler (HandleDisplayNextButtonClicked); sidebar = new Sidebar (); ViewModeChanged += sidebar.HandleMainWindowViewModeChanged; sidebar_vbox.Add (sidebar); tag_selection_scrolled = new ScrolledWindow (); tag_selection_scrolled.ShadowType = ShadowType.In; tag_selection_widget = new TagSelectionWidget (db.Tags); tag_selection_scrolled.Add (tag_selection_widget); sidebar.AppendPage (tag_selection_scrolled, Catalog.GetString ("Tags"), "tag"); AddinManager.AddExtensionNodeHandler ("/FSpot/Sidebar", OnSidebarExtensionChanged); sidebar.Context = ViewContext.Library; sidebar.CloseRequested += HideSidebar; sidebar.Show (); info_box = new InfoBox (); ViewModeChanged += info_box.HandleMainWindowViewModeChanged; info_box.VersionIdChanged += delegate (InfoBox box, uint version_id) { UpdateForVersionIdChange (version_id);}; sidebar_vbox.PackEnd (info_box, false, false, 0); info_box.Context = ViewContext.Library; tag_selection_widget.Selection.Changed += HandleTagSelectionChanged; tag_selection_widget.DragDataGet += HandleTagSelectionDragDataGet; tag_selection_widget.DragDrop += HandleTagSelectionDragDrop; tag_selection_widget.DragBegin += HandleTagSelectionDragBegin; tag_selection_widget.KeyPressEvent += HandleTagSelectionKeyPress; Gtk.Drag.SourceSet (tag_selection_widget, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask, tag_target_table, DragAction.Copy | DragAction.Move); tag_selection_widget.DragDataReceived += HandleTagSelectionDragDataReceived; tag_selection_widget.DragMotion += HandleTagSelectionDragMotion; Gtk.Drag.DestSet (tag_selection_widget, DestDefaults.All, tag_dest_target_table, DragAction.Copy | DragAction.Move ); tag_selection_widget.ButtonPressEvent += HandleTagSelectionButtonPressEvent; tag_selection_widget.PopupMenu += HandleTagSelectionPopupMenu; tag_selection_widget.RowActivated += HandleTagSelectionRowActivated; LoadPreference (Preferences.TAG_ICON_SIZE); try { query = new FSpot.PhotoQuery (db.Photos); } catch (System.Exception e) { //FIXME assume any exception here is due to a corrupt db and handle that. new RepairDbDialog (e, db.Repair (), main_window); query = new FSpot.PhotoQuery (db.Photos); } UpdateStatusLabel (); query.Changed += HandleQueryChanged; db.Photos.ItemsChanged += HandleDbItemsChanged; db.Tags.ItemsChanged += HandleTagsChanged; db.Tags.ItemsAdded += HandleTagsChanged; db.Tags.ItemsRemoved += HandleTagsChanged; #if SHOW_CALENDAR FSpot.SimpleCalendar cal = new FSpot.SimpleCalendar (query); cal.DaySelected += HandleCalendarDaySelected; left_vbox.PackStart (cal, false, true, 0); #endif group_selector = new FSpot.GroupSelector (); group_selector.Adaptor = new FSpot.TimeAdaptor (query, Preferences.Get<bool> (Preferences.GROUP_ADAPTOR_ORDER_ASC)); group_selector.ShowAll (); if (zoom_scale != null) { zoom_scale.ValueChanged += HandleZoomScaleValueChanged; } view_vbox.PackStart (group_selector, false, false, 0); view_vbox.ReorderChild (group_selector, 0); find_bar = new FindBar (query, tag_selection_widget.Model); view_vbox.PackStart (find_bar, false, false, 0); view_vbox.ReorderChild (find_bar, 1); main_window.KeyPressEvent += HandleKeyPressEvent; query_widget = new FSpot.QueryWidget (query, db, tag_selection_widget); query_widget.Logic.Changed += HandleQueryLogicChanged; view_vbox.PackStart (query_widget, false, false, 0); view_vbox.ReorderChild (query_widget, 2); icon_view = new QueryView (query); icon_view.ZoomChanged += HandleZoomChanged; LoadPreference (Preferences.ZOOM); LoadPreference (Preferences.SHOW_TAGS); LoadPreference (Preferences.SHOW_DATES); LoadPreference (Preferences.SHOW_RATINGS); icon_view_scrolled.Add (icon_view); icon_view.DoubleClicked += HandleDoubleClicked; icon_view.Vadjustment.ValueChanged += HandleIconViewScroll; icon_view.GrabFocus (); new FSpot.PreviewPopup (icon_view); Gtk.Drag.SourceSet (icon_view, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask, icon_source_target_table, DragAction.Copy | DragAction.Move); icon_view.DragBegin += HandleIconViewDragBegin; icon_view.DragDataGet += HandleIconViewDragDataGet; TagMenu tag_menu = new TagMenu (null, Database.Tags); tag_menu.NewTagHandler += delegate { HandleCreateTagAndAttach (this, null); }; tag_menu.TagSelected += HandleAttachTagMenuSelected; tag_menu.Populate(); attach_tag.Submenu = tag_menu; PhotoTagMenu pmenu = new PhotoTagMenu (); pmenu.TagSelected += HandleRemoveTagMenuSelected; remove_tag.Submenu = pmenu; Gtk.Drag.DestSet (icon_view, DestDefaults.All, icon_dest_target_table, DragAction.Copy | DragAction.Move); // icon_view.DragLeave += new DragLeaveHandler (HandleIconViewDragLeave); icon_view.DragMotion += HandleIconViewDragMotion; icon_view.DragDrop += HandleIconViewDragDrop; icon_view.DragDataReceived += HandleIconViewDragDataReceived; icon_view.KeyPressEvent += HandleIconViewKeyPressEvent; photo_view = new PhotoView (query); photo_box.Add (photo_view); photo_view.DoubleClicked += HandleDoubleClicked; photo_view.KeyPressEvent += HandlePhotoViewKeyPressEvent; photo_view.UpdateStarted += HandlePhotoViewUpdateStarted; photo_view.UpdateFinished += HandlePhotoViewUpdateFinished; photo_view.View.ZoomChanged += HandleZoomChanged; // Tag typing: focus the tag entry if the user starts typing a tag icon_view.KeyPressEvent += HandlePossibleTagTyping; photo_view.KeyPressEvent += HandlePossibleTagTyping; tag_entry = new TagEntry (db.Tags); tag_entry.KeyPressEvent += HandleTagEntryKeyPressEvent; tag_entry.TagsAttached += HandleTagEntryTagsAttached; tag_entry.TagsRemoved += HandleTagEntryRemoveTags; tag_entry.Activated += HandleTagEntryActivate; tag_entry_container.Add (tag_entry); Gtk.Drag.DestSet (photo_view, DestDefaults.All, tag_target_table, DragAction.Copy | DragAction.Move); photo_view.DragMotion += HandlePhotoViewDragMotion; photo_view.DragDrop += HandlePhotoViewDragDrop; photo_view.DragDataReceived += HandlePhotoViewDragDataReceived; view_notebook.SwitchPage += HandleViewNotebookSwitchPage; group_selector.Adaptor.GlassSet += HandleAdaptorGlassSet; group_selector.Adaptor.Changed += HandleAdaptorChanged; LoadPreference (Preferences.GROUP_ADAPTOR); LoadPreference (Preferences.GROUP_ADAPTOR_ORDER_ASC); this.selection = new MainSelection (this); this.selection.Changed += HandleSelectionChanged; this.selection.ItemsChanged += HandleSelectionItemsChanged; this.selection.Changed += sidebar.HandleSelectionChanged; this.selection.ItemsChanged += sidebar.HandleSelectionItemsChanged; Mono.Addins.AddinManager.ExtensionChanged += PopulateExtendableMenus; PopulateExtendableMenus (null, null); UpdateMenus (); main_window.ShowAll (); tagbar.Hide (); find_bar.Hide (); UpdateFindByTagMenu (); LoadPreference (Preferences.SHOW_TOOLBAR); LoadPreference (Preferences.SHOW_SIDEBAR); LoadPreference (Preferences.SHOW_TIMELINE); LoadPreference (Preferences.SHOW_FILMSTRIP); LoadPreference (Preferences.GNOME_MAILTO_ENABLED); Preferences.SettingChanged += OnPreferencesChanged; main_window.DeleteEvent += HandleDeleteEvent; query_widget.HandleChanged (query); query_widget.Hide (); // When the icon_view is loaded, set it's initial scroll position icon_view.SizeAllocated += HandleIconViewReady; export.Activated += HandleExportActivated; UpdateToolbar (); Banshee.Kernel.Scheduler.Resume (); }