public PanelConstruction(VisualControl parent, int shiftX, int shiftY) : base(parent, shiftX, shiftY) { btnBuyOrUpgrade = new VCIconButton(this, imgMapObject.NextLeft(), imgMapObject.ShiftY, Program.formMain.ilGui, FormMain.GUI_BUILD); btnBuyOrUpgrade.Click += BtnBuyOrUprgade_Click; btnBuyOrUpgrade.ShowHint += BtnBuyOrUpgrade_ShowHint; btnHeroes = new VCIconButton(this, imgMapObject.ShiftX, imgMapObject.NextTop(), Program.formMain.imListObjectsCell, -1); //if ((TypeConstruction.TrainedHero != null) && !(TypeConstruction is TypeEconomicConstruction)) //{ btnHireHero = new VCIconButton(this, imgMapObject.NextLeft(), btnBuyOrUpgrade.NextTop(), Program.formMain.imListObjectsCell, -1); btnHireHero.Click += BtnHireHero_Click; btnHireHero.ShowHint += BtnHireHero_ShowHint; //} //else // btnHeroes.Visible = false; //if (TypeConstruction is TypeEconomicConstruction) //{ lblIncome = new VCLabelValue(this, imgMapObject.NextLeft() - (FormMain.Config.GridSize * 4), imgMapObject.NextTop(), Color.Green); lblIncome.ImageIndex = FormMain.GUI_16_INCOME; lblIncome.StringFormat.Alignment = StringAlignment.Near; //} Height = btnHeroes.NextTop(); Width = btnBuyOrUpgrade.NextLeft(); lblNameMapObject.Width = Width - (lblNameMapObject.ShiftX * 2); }
public VCImage(VisualControl parent, int shiftX, int shiftY, BitmapList bitmapList, int imageIndex) : base(parent, shiftX, shiftY) { BitmapList = bitmapList; ImageIndex = imageIndex; labelCost = new VCLabelM2(this, 0, Height - 12, Program.formMain.fontSmallC, FormMain.Config.CommonCost, 16, ""); labelCost.StringFormat.LineAlignment = StringAlignment.Far; labelCost.Visible = false;// Текст перекрывается иконкой. Поэтому рисуем вручную labelCost.ManualDraw = true; shiftlabelLevel = bitmapList.Size >= 128 ? FormMain.Config.GridSize : 6; labelLevel = new VCLabelM2(this, 0, shiftlabelLevel - 2, Program.formMain.fontMedCaptionC, FormMain.Config.CommonLevel, 16, ""); labelLevel.StringFormat.LineAlignment = StringAlignment.Near; labelLevel.StringFormat.Alignment = StringAlignment.Far; labelLevel.Visible = false; labelLevel.ManualDraw = true; labelQuantity = new VCLabelM2(this, 0, FormMain.Config.GridSize, Program.formMain.fontMedCaptionC, FormMain.Config.CommonQuantity, 16, ""); labelQuantity.StringFormat.LineAlignment = StringAlignment.Far; labelQuantity.StringFormat.Alignment = StringAlignment.Far; labelQuantity.Visible = false; labelQuantity.ManualDraw = true; labelPopupQuantity = new VCLabelM2(this, 0, 0, Program.formMain.fontSmall, FormMain.Config.CommonPopupQuantity, sizePopupBackground, ""); labelPopupQuantity.StringFormat.LineAlignment = StringAlignment.Center; labelPopupQuantity.StringFormat.Alignment = StringAlignment.Center; labelPopupQuantity.Width = sizePopupBackground; labelPopupQuantity.Visible = false; labelPopupQuantity.ManualDraw = true; brushPopupQuantity = new SolidBrush(FormMain.Config.CommonPopupQuantityBack); ValidateSize(); }
/// <summary> /// Initialize a new instance of the ViewControl class. /// </summary> /// <param name="rootControl">Top level visual control.</param> public ViewControl(VisualControl rootControl) { Debug.Assert(rootControl != null); // We use double buffering to reduce drawing flicker SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); // We need to repaint entire control whenever resized SetStyle(ControlStyles.ResizeRedraw, true); // We are not selectable SetStyle(ControlStyles.Selectable, false); // Default TransparentBackground = false; InDesignMode = false; // Remember incoming references _rootControl = rootControl; // Create delegate so child elements can request a repaint NeedPaintDelegate = OnNeedPaint; }
private void setNewVisualControl(VisualControlInfo vc) { if (_activeVisualControl != null) { _activeVisualControl.Stop(); _activeVisualControl.Visible = false; _activeVisualControl.Parent = null; _activeVisualControl.Enabled = false; } _activeVisualControl = vc.control; _activeVisualControl.Parent = MainPanel; _activeVisualControl.Dock = DockStyle.Fill; _activeVisualControl.Visible = true; _activeVisualControl.Enabled = true; this.Text = vc.control.ToString() + " - " + _profile.Name; //this.MaximumSize = new System.Drawing.Size(this.Width, this.Height); _widthWithoutEffectsPanel = this.Width; //EffectsPanel.Left = this.Width - 14; //EffectsPanel.Top = ControlButtonsGroupBox.Top + 7; //EffectsPanel.Height = vc.height + MainPanel.Top - EffectsPanel.Top; //EffectsPanel.Dele MainPanel.Width = vc.width; MainPanel.Height = vc.height; this.Height = MainPanel.Top + MainPanel.Height + 28; //vc.height + 121; this.Width = MainPanel.Left + MainPanel.Width + 9; //vc.width + 10; ControlButtonsGroupBox.Left = (MainPanel.Width - ControlButtonsGroupBox.Width) / 2; SetEffectsDefaultLocation(); updateEffectsPanels(); this.Refresh(); }
internal void AddControl(VisualControl vc) { Debug.Assert(vc != null); Debug.Assert(Controls.IndexOf(vc) == -1); Controls.Add(vc); }
public VCWindowCaption(VisualControl parent, int shiftX, int shiftY) : base(parent, shiftX, shiftY) { labelCaption = new VCLabelM2(this, WidthCap(), 1, Program.formMain.fontBigCaption, Color.MediumAquamarine, Program.formMain.fontBigCaption.MaxHeightSymbol, ""); labelCaption.StringFormat.Alignment = StringAlignment.Center; labelCaption.StringFormat.LineAlignment = StringAlignment.Near; labelCaption.ManualDraw = true; }
private void Awake() { if (instance == null) { instance = this; } }
/// <summary> /// Gets and sets the root control for point translation and message dispatch. /// </summary> /// <param name="parent">Parent control.</param> public void UpdateParent(Control parent) { // Keep looking till we run out of parents while (parent != null) { // We can hook into a visual control derived class if (parent is VisualControl control) { _rootControl = control; _rootPopup = null; break; } // We can hook into a visual popup derived class if (parent is VisualPopup popup) { _rootControl = null; _rootPopup = popup; break; } // Move up another level parent = parent.Parent; } }
public VCForm() { ClientControl = new VisualControl(this, 14, 13 + 24); ClientControl.Width = 440; ClientControl.Height = 200; windowCaption = new VCWindowCaption(this, 0, 0); }
public VCLabelValue(VisualControl parent, int shiftX, int shiftY, Color foreColor) : base(parent, shiftX, shiftY, Program.formMain.fontMedCaption, foreColor, 16, "") { BitmapList = Program.formMain.ilGui16; StringFormat.Alignment = StringAlignment.Near; TopMargin = -2; }
override public void Init(VisualControl parent, Configer conf) { base.Init(parent, conf); Button mouse = ((Speaker)parent).GetFaceElemByName("MouseButton"); _mouseArg = new FaceControlArg(mouse); _baseMouseArg = new FaceControlArg(mouse); loadSoundMouseLocations(); }
public VCCheckBox(VisualControl parent, int shiftX, int shiftY, string text) : base(parent, shiftX, shiftY, Program.formMain.fontParagraph, Color.PaleTurquoise, 24, text) { StringFormat.Alignment = StringAlignment.Near; StringFormat.LineAlignment = StringAlignment.Center; Width = 160; LeftMargin = 32; BitmapList = Program.formMain.blCheckBox; }
public VCTabControl(VisualControl parent, int shiftX, int shiftY, BitmapList bitmapList) : base(parent, shiftX, shiftY) { BitmapList = bitmapList; ActivePage = -1; lblCaptionPage = new VCLabelM2(this, 0, BitmapList.Size + FormMain.Config.GridSize, Program.formMain.fontSmallBC, FormMain.Config.CommonCaptionPage, 24, ""); lblCaptionPage.StringFormat.LineAlignment = StringAlignment.Center; lblCaptionPage.ShowBorder = true; lblCaptionPage.Color = Color.LightGreen; }
public VCButton(VisualControl parent, int shiftX, int shiftY, string caption) : base(parent, shiftX, shiftY) { Caption = caption; Width = 160; labelCaption = new VCLabelM2(this, WidthCap(), 1, Program.formMain.fontSmallC, Color.White, GetBitmap().Height, ""); labelCaption.StringFormat.Alignment = StringAlignment.Center; labelCaption.StringFormat.LineAlignment = StringAlignment.Center; labelCaption.Visible = false; labelCaption.ManualDraw = true; }
internal override VisualControl GetControl(int x, int y) { VisualControl vc = base.GetControl(x, y); if (vc != null) { return(vc); } return(Page.GetControl(x, y)); }
public VCCell(VisualControl parent, int shiftX, int shiftY) : base(parent, shiftX, shiftY, Program.formMain.ilItems, -1) { HighlightUnderMouse = true; ShiftImageX = 2; ShiftImageY = 0; // Ставим размеры после изменения ShiftImageX и ShiftImageY, так так там меняется размер ячейки Width = Program.formMain.bmpBorderForIcon.Width; Height = Program.formMain.bmpBorderForIcon.Height; DrawState = true; }
public PanelHeroInfo(VisualControl parent, int shiftX, int shiftY) : base(parent, shiftX, shiftY) { btnTarget = new VCCell(this, panelSpecialization.ShiftX, panelSpecialization.NextTop()); btnTarget.ShowHint += BtnTarget_ShowHint; btnTarget.Click += BtnTarget_Click; btnDismiss = new Button() { //Parent = this, Left = LeftAfterIcon(), Top = TopForIcon(), //ImageList = Program.formMain.ilGui, ImageIndex = FormMain.GUI_DISMISS //Size = GuiUtils.SizeButtonWithImage(Program.formMain.ilGui) }; btnDismiss.Click += BtnDismiss_Click; return; /*lblLevel = GuiUtils.CreateLabel(this, Config.GRID_SIZE, TopForControls()); * lblHealth = GuiUtils.CreateLabel(this, Config.GRID_SIZE, lblLevel.Top + lblLevel.Height + Config.GRID_SIZE); * lblMana = GuiUtils.CreateLabel(this, Config.GRID_SIZE, lblHealth.Top + lblHealth.Height + Config.GRID_SIZE); * * lblStrength = GuiUtils.CreateLabelParameter(this, Config.GRID_SIZE, lblMana.Top + lblMana.Height + Config.GRID_SIZE, FormMain.GUI_PARAMETER_STRENGTH); * lblDexterity = GuiUtils.CreateLabelParameter(this, Config.GRID_SIZE, lblStrength.Top + lblStrength.Height + Config.GRID_SIZE, FormMain.GUI_PARAMETER_DEXTERITY); * lblMagic = GuiUtils.CreateLabelParameter(this, Config.GRID_SIZE, lblDexterity.Top + lblDexterity.Height + Config.GRID_SIZE, FormMain.GUI_PARAMETER_MAGIC); * lblVitality = GuiUtils.CreateLabelParameter(this, Config.GRID_SIZE, lblMagic.Top + lblMagic.Height + Config.GRID_SIZE, FormMain.GUI_PARAMETER_VITALITY); * lblSpeed = GuiUtils.CreateLabelParameter(this, Config.GRID_SIZE, lblVitality.Top + lblVitality.Height + Config.GRID_SIZE, FormMain.GUI_PARAMETER_SPEED_ATTACK); * * // lblStamina = GuiUtils.CreateLabelParameter(this, Config.GRID_SIZE, lblWisdom.Top + lblWisdom.Height + Config.GRID_SIZE, FormMain.GUI_PARAMETER_STAMINA); * lblAttackMelee = GuiUtils.CreateLabelParameter(this, lblStrength.Left + lblStrength.Width + Config.GRID_SIZE, lblStrength.Top, FormMain.GUI_PARAMETER_ATTACK_MELEE); * lblAttackRange = GuiUtils.CreateLabelParameter(this, lblDexterity.Left + lblDexterity.Width + Config.GRID_SIZE, lblDexterity.Top, FormMain.GUI_PARAMETER_ATTACK_RANGE); * lblAttackMagic = GuiUtils.CreateLabelParameter(this, lblMagic.Left + lblMagic.Width + Config.GRID_SIZE, lblMagic.Top, FormMain.GUI_PARAMETER_ATTACK_MAGIC); * * lblDefenseMelee = GuiUtils.CreateLabelParameter(this, lblAttackMelee.Left + lblAttackMelee.Width + Config.GRID_SIZE, lblAttackMelee.Top, FormMain.GUI_PARAMETER_DEFENSE_MELEE); * lblDefenseRange = GuiUtils.CreateLabelParameter(this, lblAttackRange.Left + lblAttackRange.Width + Config.GRID_SIZE, lblAttackRange.Top, FormMain.GUI_PARAMETER_DEFENSE_RANGE); * lblDefenseMagic = GuiUtils.CreateLabelParameter(this, lblAttackMagic.Left + lblAttackMagic.Width + Config.GRID_SIZE, lblAttackMagic.Top, FormMain.GUI_PARAMETER_DEFENSE_MAGIC); * * // Слоты инвентаря * PanelEntity pb; * for (int y = 0; y < FormMain.SLOTS_LINES; y++) * { * for (int x = 0; x < FormMain.SLOTS_IN_LINE; x++) * { * pb = new PanelEntity(); * pb.Parent = this; * pb.Left = Config.GRID_SIZE + ((pb.Width + Config.GRID_SIZE) * x); * pb.Top = GuiUtils.NextTop(lblSpeed) + ((pb.Height + Config.GRID_SIZE) * y); * * slots[x + y * FormMain.SLOTS_IN_LINE] = pb; * } * }*/ }
public VCToolLabel(VisualControl parent, int shiftX, int shiftY, string text, int imageIndex) : base(parent, shiftX, shiftY, Program.formMain.fontMedCaption, Color.White, 26, text) { StringFormat.Alignment = StringAlignment.Near; StringFormat.LineAlignment = StringAlignment.Near; BitmapList = Program.formMain.ilGui16; ImageIndex = imageIndex; Width = 80; TopMargin = 1; ShiftImage = new Point(6, 4); }
public WindowPreferences() : base() { windowCaption.Caption = "Настройки"; vcPanelGame = new VisualControl(ClientControl, 0, 0); vcPanelGame.ShowBorder = true; lblCaptionPanelGame = new VCLabelM2(vcPanelGame, FormMain.Config.GridSize, 8, Program.formMain.fontMedCaption, Color.PaleTurquoise, 24, "Общие настройки:"); lblCaptionPanelGame.StringFormat.Alignment = StringAlignment.Near; chkbShowSplashVideo = new VCCheckBox(vcPanelGame, FormMain.Config.GridSize, lblCaptionPanelGame.NextTop(), "Показывать видео-заставку"); chkbShowSplashVideo.Width = 320; chkbWindowMode = new VCCheckBox(vcPanelGame, FormMain.Config.GridSize, chkbShowSplashVideo.NextTop(), "Оконный режим"); chkbWindowMode.Width = 320; chkbCheckUpdates = new VCCheckBox(vcPanelGame, FormMain.Config.GridSize, chkbWindowMode.NextTop(), "Проверять обновления при запуске"); chkbCheckUpdates.Width = 320; vcPanelGame.ApplyMaxSize(); vcPanelGame.Height += 8; lblCaptionPanelGame.Width = vcPanelGame.Width - (FormMain.Config.GridSize * 2); vcPanelBatttlefield = new VisualControl(ClientControl, 0, vcPanelGame.NextTop()); vcPanelBatttlefield.ShowBorder = true; lblCaptionPanelBattlefield = new VCLabelM2(vcPanelBatttlefield, FormMain.Config.GridSize, 8, Program.formMain.fontMedCaption, Color.PaleTurquoise, 24, "Настройки битвы:"); lblCaptionPanelBattlefield.StringFormat.Alignment = StringAlignment.Near; chkbShowPath = new VCCheckBox(vcPanelBatttlefield, FormMain.Config.GridSize, lblCaptionPanelBattlefield.NextTop(), "Показывать путь юнитов"); chkbShowPath.Width = 320; chkbShowGrid = new VCCheckBox(vcPanelBatttlefield, FormMain.Config.GridSize, chkbShowPath.NextTop(), "Показывать сетку"); chkbShowGrid.Width = 320; vcPanelBatttlefield.ApplyMaxSize(); vcPanelBatttlefield.Height += 8; lblCaptionPanelBattlefield.Width = vcPanelBatttlefield.Width - (FormMain.Config.GridSize * 2); btnAccept = new VCButton(ClientControl, 0, vcPanelBatttlefield.NextTop() + (FormMain.Config.GridSize * 2), "Принять"); btnAccept.Width = 160; btnAccept.Click += BtnAccept_Click; btnDefault = new VCButton(ClientControl, btnAccept.NextLeft(), btnAccept.ShiftY, "Базовые"); btnDefault.Width = 160; btnDefault.Click += BtnDefault_Click; btnCancel = new VCButton(ClientControl, btnDefault.NextLeft(), btnAccept.ShiftY, "Отмена"); btnCancel.Width = 160; btnCancel.Click += BtnCancel_Click; AcceptButton = btnAccept; CancelButton = btnCancel; ClientControl.Width = btnCancel.ShiftX + btnCancel.Width + btnCancel.Left; ClientControl.Height = btnCancel.NextTop(); vcPanelGame.Width = ClientControl.Width - (vcPanelGame.ShiftX * 2); vcPanelBatttlefield.Width = ClientControl.Width - (vcPanelBatttlefield.ShiftX * 2); }
public PanelMapObject(VisualControl parent, int shiftX, int shiftY) : base(parent, shiftX, shiftY) { ShowBorder = true; lblNameMapObject = new VCLabelM2(this, FormMain.Config.GridSize, FormMain.Config.GridSize - 3, Program.formMain.fontMedCaptionC, Color.Transparent, FormMain.Config.GridSize * 3, ""); lblNameMapObject.StringFormat.Alignment = StringAlignment.Center; lblNameMapObject.ShowBorder = true; lblNameMapObject.Click += ImgLair_Click; imgMapObject = new VCImageBig(this, lblNameMapObject.NextTop()); imgMapObject.HighlightUnderMouse = true; imgMapObject.Click += ImgLair_Click; imgMapObject.ShowHint += ImgLair_ShowHint; Click += ImgLair_Click; }
internal void DrawHint(VisualControl c, bool delayShow = true) { if (!ExistHint) { return; } Debug.Assert(c.Width > 8); Debug.Assert(c.Height > 8); Debug.Assert(lblHeader.Text.Length > 0); Height = nextTop; Point l = new Point(c.Left - Program.formMain.ShiftControls.X, c.Top + c.Height + 4 - Program.formMain.ShiftControls.Y); // Если подсказка уходит за пределы экрана игры, меняем ее положение if (l.X + Width > Program.formMain.sizeGamespace.Width - FormMain.Config.GridSize) { l.X = Program.formMain.sizeGamespace.Width - Width - FormMain.Config.GridSize; } if (l.Y + Height > Program.formMain.sizeGamespace.Height - FormMain.Config.GridSize) { l.Y = l.Y - Height - c.Height - 7; } // Если подсказка не помещается ни снизу, ни сверху, показываем ее справа или слева if (l.Y < 0) { l.Y = Program.formMain.sizeGamespace.Height - FormMain.Config.GridSize - Height; // Здесь нужна проверка на то, где рисовать - слева или справа l.X = c.Left + c.Width + 4; } // Сначала меняем высоту, а потом меням координату, чтобы при ArrangeControls не срабатывал Assert SetPos(l.X + Program.formMain.ShiftControls.X, l.Y + Program.formMain.ShiftControls.Y); bool needReshow = (Visible == false) || (Height != nextTop); bmpBackground?.Dispose(); bmpBackground = new Bitmap(Width, Height); Graphics g = Graphics.FromImage(bmpBackground); g.Clear(colorBackground); g.Dispose(); ArrangeControls(); }
public VCLabelM2(VisualControl parent, int shiftX, int shiftY, M2Font font, Color foreColor, int height, string text) : base(parent, shiftX, shiftY) { Height = height; Text = text; Font = font; Color = foreColor; StringFormat = new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Near }; LeftMargin = 0; // Рисуем выше на два пиксела и увеличиваем высоту, так как у текст сверху пустота, а снизу происходит обрезка, // хотя по высоте все вмещается TopMargin = 0; }
/// <inheritdoc/> public void Add(Control item) { if (item is VisualControl) { VisualControl visualControl = item as VisualControl; if (!this.owner.ScreenRectangle.Contains(visualControl.ScreenRectangle) && !(this.owner is ComboBox)) { visualControl.Location = new Point(this.owner.Style.BorderThickness, this.owner.Style.BorderThickness); if (this.owner is Form) { Form form = this.owner as Form; visualControl.Location = new Point(visualControl.Location.X, visualControl.Location.Y + form.CaptionBar.Height); } } } item.Parent = this.owner; this.controls.Add(item); }
public VCFormPage(VisualControl parent, int shiftX, int shiftY, List <VCFormPage> list, BitmapList bitmapList, int imageIndex, string caption, EventHandler onClick) : base(parent, shiftX, shiftY, bitmapList, imageIndex) { UseFilter = false; HighlightUnderMouse = true; Caption = caption; Page = new VisualControl() { Visible = false }; Page.Click += Page_Click; Click += onClick; listPages = list; indexInList = listPages.Count; listPages.Add(this); ArrangeControls(); }
public PanelLair(VisualControl parent, int shiftX, int shiftY) : base(parent, shiftX, shiftY) { btnAction = new VCIconButton(this, imgMapObject.NextLeft(), imgMapObject.ShiftY, Program.formMain.ilGui, FormMain.GUI_BATTLE); btnAction.Click += BtnAction_Click; btnAction.ShowHint += BtnAction_ShowHint; btnCancel = new VCIconButton(this, btnAction.ShiftX, btnAction.NextTop(), Program.formMain.ilGui, FormMain.GUI_FLAG_CANCEL); btnCancel.Click += BtnCancel_Click; btnCancel.ShowHint += BtnCancel_ShowHint; btnInhabitants = new VCIconButton(this, imgMapObject.ShiftX, imgMapObject.NextTop(), Program.formMain.ilGui, FormMain.GUI_HOME); btnInhabitants.Click += BtnInhabitants_Click; btnInhabitants.ShowHint += BtnInhabitants_ShowHint; btnHeroes = new VCIconButton(this, btnInhabitants.NextLeft(), btnInhabitants.ShiftY, Program.formMain.ilGui, FormMain.GUI_TARGET); btnHeroes.Click += BtnHeroes_Click; btnHeroes.ShowHint += BtnHeroes_ShowHint; Height = btnInhabitants.NextTop(); Width = btnAction.NextLeft(); }
public PanelBuildingInfo(VisualControl parent, int shiftX, int shiftY) : base(parent, shiftX, shiftY) { panelProducts = new PanelWithPanelEntity(4); panelInhabitants = new PanelWithPanelEntity(4); panelWarehouse = new PanelWithPanelEntity(4); lblGold = new VCLabel(this, FormMain.Config.GridSize, TopForControls(), FormMain.Config.FontCost, Color.White, 16, ""); lblGold.Width = 80; lblGold.BitmapList = Program.formMain.ilGui16; lblGold.ImageIndex = FormMain.GUI_16_GOLD; separator.ShiftY = lblGold.NextTop(); pageControl.ShiftY = separator.NextTop(); pageControl.AddTab("Товары", FormMain.GUI_GOODS, panelProducts); pageControl.AddTab("Склад", FormMain.GUI_INVENTORY, panelWarehouse); pageControl.AddTab("Жители", FormMain.GUI_HOME, panelInhabitants); pageControl.AddTab("История", FormMain.GUI_BOOK, null); pageControl.ApplyMinSize(); Width = pageControl.Width + FormMain.Config.GridSize * 2; }