Ejemplo n.º 1
0
		public NavigatorMenu(Navigator nav, bool swapItem) {
			Navigator = nav;

			back = new ToolStripButton { Text = "←" };
			fore = new ToolStripButton { Text = "→" };
			end = new ToolStripButton { Text = "end" };
			edit = new ToolStripButton { Text = "edit" };
			if (swapItem)
				swap = new ToolStripButton { Text = "swap phrase/translation" };
			position = new ToolStripLabel { Alignment = ToolStripItemAlignment.Right };

			Menu = new ToolStrip();
			foreach (var button in Buttons) {
				button.Alignment = ToolStripItemAlignment.Right;
				Menu.Items.Add(button);
			}
			Menu.Items.Add(position);

			back.Click += delegate { Raise(Back); };
			fore.Click += delegate { Raise(Forward); };
			end.Click += delegate { Raise(End); };
			edit.Click += delegate { Raise(Edit); };
			if (swapItem)
				swap.Click += delegate { Raise(Swap); };
		}
Ejemplo n.º 2
0
		public override void Start(IPracticeWindow owner) {
			base.Start(owner);

			swap = false;
			nav = new Navigator(owner);
			navMenu = new NavigatorMenu(nav, true);

			MergeMenu(navMenu.Menu);

			phraseLabel = new Label();
			translationLabel = new Label();
			translationLabel.ForeColor = System.Drawing.SystemColors.GrayText;

			bigFont = new System.Drawing.Font(GameArea.FindForm().Font.FontFamily, 24);
			smallFont = new System.Drawing.Font(GameArea.FindForm().Font.FontFamily, 16);

			foreach (var l in new[] { phraseLabel, translationLabel }) {
				l.AutoSize = true;
				l.Font = bigFont;
				l.BackColor = Color.Transparent;
				GameArea.Controls.Add(l);
			}

			GameArea.Resize += GameArea_Resize;
			GameArea.PreviewKeyDown += GameArea_PreviewKeyDown;

			foreach (Control c in new Control[] { phraseLabel, translationLabel, GameArea }) {
				c.MouseUp += GameArea_MouseUp;
			}

			navMenu.Back += delegate { GoBack(); };
			navMenu.Forward += delegate { GoForward(); };
			navMenu.End += delegate { GoToEnd(); };
			navMenu.Edit += delegate {
				var newItem = Dialogs.EditPracticeItem.Show(nav.CurrentItem);
				if (newItem != null)
					nav.UpdateCurrentItem(newItem);
				Update();
				Layout();
			};
			navMenu.Swap += delegate { SwapItems(); };

			translationLabel.Visible = false;
			Update();
			Layout();
		}