public MpeSelectButton() : base() { MpeLog.Debug("MpeSelectButton()"); Type = MpeControlType.SelectButton; layoutStyle = MpeLayoutStyle.HorizontalFlow; autoSize = false; active = false; offset = Point.Empty; textureSize = new Size(32, 32); items = new MpeItemManager(); items.Type = MpeItemType.Text; items.TypeChanging += new MpeItemManager.TypeChangingHandler(OnItemTypeChanging); leftImage = new MpeImage(); leftImage.Embedded = true; leftImage.AutoSize = false; leftImage.Size = textureSize; leftImage.Padding = new MpeControlPadding(8); rightImage = new MpeImage(); rightImage.Embedded = true; rightImage.AutoSize = false; rightImage.Size = textureSize; rightImage.Padding = new MpeControlPadding(8); label = new MpeLabel(); label.Embedded = true; Prepare(); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context.Instance is MpeControl) { try { MpeControl mpc = (MpeControl)context.Instance; IWindowsFormsEditorService editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); MpeTextAreaEditorForm selector = new MpeTextAreaEditorForm((string)value, editorService); editorService.DropDownControl(selector); if (selector.Result == DialogResult.Cancel) { return(value); } return(selector.TextValue); } catch (Exception ee) { MpeLog.Debug(ee); MpeLog.Error(ee); } } return(base.EditValue(context, provider, value)); }
public override void Initialize() { try { AllowDrop = false; PropertyManager.HideResourceList(); if (font != null) { screen = (MpeScreen)Parser.GetControl(MpeControlType.Screen); viewer = new MpeFontViewer(font, screen.TextureBack); viewer.Location = new Point(Mask.NodeSize, Mask.NodeSize); viewer.SelectedIndexChanged += new MpeFontViewer.SelectedIndexChangedHandler(OnViewerIndexChanged); viewer.Modified = false; Controls.Add(viewer); } MpeLog.Info("Font designer initialized [" + ResourceName + "]"); } catch (MpeParserException mpe) { MpeLog.Debug(mpe); throw new DesignerException(mpe.Message); } catch (Exception e) { MpeLog.Debug(e); throw new DesignerException(e.Message); } }
public void OnControlClick(object sender, EventArgs e) { if (activeMouseEvent != null) { if (mask.SelectedControl != sender && (sender is MaskComponent) == false) { try { mask.SelectedControl = (MpeControl)sender; Focus(); UpdatePropertyManager(); } catch (Exception ee) { MpeLog.Debug(ee); MpeLog.Error(ee); } } if (activeMouseEvent.Button == MouseButtons.Right) { if (sender != null && sender is Control) { Control c = (Control)sender; UpdateContextMenu(mask.SelectedControl); MenuCommand mc = contextMenu.TrackPopup(c.PointToScreen(new Point(activeMouseEvent.X, activeMouseEvent.Y)), false); OnMenuSelection(mc); } } activeMouseEvent = null; } }
private void OnPanelClick(object sender, StatusBarPanelClickEventArgs e) { if (e.StatusBarPanel == iconPanel && sender == this) { MenuCommand c = menu.TrackPopup(PointToScreen(new Point(0, -90)), false); if (c != null) { switch (c.Text) { case "Debug": MpeLog.Threshold = MpeLogLevel.Debug; MpeLog.Debug("Log Level set to Debug"); break; case "Info": MpeLog.Threshold = MpeLogLevel.Info; MpeLog.Info("Log Level set to Info"); break; case "Warn": MpeLog.Threshold = MpeLogLevel.Warn; MpeLog.Warn("Log Level set to Warn"); break; case "Error": MpeLog.Threshold = MpeLogLevel.Error; MpeLog.Error("Log Level set to Error"); break; } } } }
private void ReleaseControl(MpeControl c) { MpeLog.Debug("Removing " + c.ToString()); if (c is MpeContainer) { for (int i = 0; i < c.Controls.Count; i++) { if (c.Controls[i] is MpeControl) { ReleaseControl((MpeControl)c.Controls[i]); } } c.ControlAdded -= new ControlEventHandler(OnControlAdded); c.ControlRemoved -= new ControlEventHandler(OnControlRemoved); if (AllowAdditions) { c.DragDrop -= new DragEventHandler(OnDragDrop); c.DragEnter -= new DragEventHandler(OnDragEnter); } } c.Click -= new EventHandler(OnControlClick); c.MouseDown -= new MouseEventHandler(OnControlMouseDown); c.StatusChanged -= new MpeControl.StatusChangedHandler(OnControlStatusChanged); c.KeyUp -= new KeyEventHandler(OnKeyUp); c.PropertyValueChanged -= new MpeControl.PropertyValueChangedHandler(OnControlPropertyValueChanged); c.IdentityChanged -= new MpeControl.IdentityChangedHandler(OnControlIdentityChanged); ResourceList.Remove(c); MpeLog.Debug("Removed " + c.ToString()); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context.Instance is MpeControl) { try { MpeControl mpc = (MpeControl)context.Instance; IWindowsFormsEditorService editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); MpeImageEditorForm selector = new MpeImageEditorForm((FileInfo)value, mpc.Parser, editorService); editorService.DropDownControl(selector); if (selector.SelectedImageName == null) { MpeLog.Info("Clearing Image..."); return(null); } MpeLog.Info("Changing texture to [" + selector.SelectedImageName + "]"); return(mpc.Parser.GetImageFile(selector.SelectedImageName)); } catch (Exception ee) { MpeLog.Debug(ee); MpeLog.Error(ee); } } return(base.EditValue(context, provider, value)); }
protected override void PrepareControl() { MpeLog.Debug("MpeLabel.Prepare()"); if (font != null) { Rectangle r0 = Rectangle.Empty; if (screen != null) { r0 = font.GetStringRectangle(textValue, screen.Size); } else { r0 = font.GetStringRectangle(textValue, new Size(640, 480)); } textSize = r0.Size; if (Alignment == MpeControlAlignment.Left) { textOffset = new Point(Padding.Left - r0.X, Padding.Top - r0.Y); } else { textOffset = new Point(Width - Padding.Right - textSize.Width - r0.X, Padding.Top - r0.Y); } if (AutoSize && (Type == MpeControlType.Label || Type == MpeControlType.FadeLabel)) { int r = Right; Size = new Size(textSize.Width + Padding.Left + Padding.Right, textSize.Height + Padding.Top + Padding.Bottom); if (alignment == MpeControlAlignment.Right) { Left = r - Width; } } } MpeLog.Debug("MpeLabel.Prepare().end"); }
public override void Load(XPathNodeIterator iterator, MpeParser parser) { MpeLog.Debug("MpeImage.Load()"); this.parser = parser; AutoSize = false; base.Load(iterator, parser); Texture = parser.GetImageFile(iterator, "texture", Texture); tags.Remove("texture"); if (parser.GetInt(iterator, "width", -1) < 0 || parser.GetInt(iterator, "height", -1) < 0) { if (Texture == null) { AutoSize = false; Size = new Size(64, 64); } else { AutoSize = true; } } Centered = parser.GetBoolean(iterator, "centered", Centered); tags.Remove("centered"); Filtered = parser.GetBoolean(iterator, "filtered", Filtered); tags.Remove("filtered"); KeepAspectRatio = parser.GetBoolean(iterator, "keepaspectratio", KeepAspectRatio); tags.Remove("keepaspectratio"); ColorKey = parser.GetInt(iterator, "colorkey", ColorKey); tags.Remove("colorkey"); Modified = false; }
//private MpeAnimationType animation; #endregion #region Constructors public MpeGroup() : base() { MpeLog.Debug("MpeGroup()"); Type = MpeControlType.Group; AllowDrop = true; //animation = MpeAnimationType.None; }
public MpeGroup(MpeGroup group) : base(group) { MpeLog.Debug("MpeGroup(group)"); Type = MpeControlType.Group; AllowDrop = true; //animation = group.animation; }
public override void Load(XPathNodeIterator iterator, MpeParser parser) { MpeLog.Debug("MpeLabel.Load()"); base.Load(iterator, parser); this.parser = parser; Text = parser.GetString(iterator, "label", "label"); tags.Remove("label"); Alignment = parser.GetAlignment(iterator, "align", Alignment); tags.Remove("align"); if (Alignment == MpeControlAlignment.Right) { Left = Left - Width; } TextColor = parser.GetColor(iterator, "textcolor", TextColor); tags.Remove("textcolor"); DisabledColor = parser.GetColor(iterator, "disabledcolor", DisabledColor); tags.Remove("disabledcolor"); Font = parser.GetFont(iterator, "font", Font); tags.Remove("font"); if (Type == MpeControlType.Label || Type == MpeControlType.FadeLabel) { AutoSize = true; } Prepare(); Modified = false; }
public override void Load(XPathNodeIterator iterator, MpeParser parser) { base.Load(iterator, parser); MpeLog.Debug("MpeCheckBox.Load()"); this.parser = parser; label.Load(iterator, parser); label.Enabled = false; tags.Remove("label"); tags.Remove("align"); tags.Remove("textcolor"); tags.Remove("disabledcolor"); tags.Remove("font"); // Textures Texture = parser.GetImageFile(iterator, "textureCheckmarkNoFocus", Texture); tags.Remove("textureCheckmarkNoFocus"); TextureChecked = parser.GetImageFile(iterator, "textureCheckmark", TextureChecked); tags.Remove("textureCheckmark"); int w = parser.GetInt(iterator, "MarkWidth", TextureSize.Width); tags.Remove("MarkWidth"); int h = parser.GetInt(iterator, "MarkHeight", TextureSize.Height); tags.Remove("MarkHeight"); TextureSize = new Size(w, h); Modified = false; }
public override void Initialize() { try { AllowDrop = false; screen = (MpeScreen)Parser.CreateControl(MpeControlType.Screen); screen.Location = new Point(Mask.NodeSize, Mask.NodeSize); Controls.Add(screen); if (control.Type != MpeControlType.Screen) { screen.Controls.Add(control); } else { control = screen; } control.IsReference = true; control.Modified = false; MpeLog.Info("Control designer intialized [" + control.Type.DisplayName + "]"); } catch (MpeParserException mpe) { MpeLog.Debug(mpe); throw new DesignerException(mpe.Message); } catch (Exception e) { MpeLog.Debug(e); throw new DesignerException(e.Message); } }
protected void FireStatusChanged() { if (StatusChanged != null) { MpeLog.Debug("MpeControl.FireStatusChanged(" + modified + ")"); StatusChanged(this, modified); } }
protected void FirePropertyValueChanged(string propertyName) { if (PropertyValueChanged != null) { MpeLog.Debug("MpeControl.FirePropertyValueChanged(" + propertyName + ", " + modified + ")"); PropertyValueChanged(this, propertyName); } }
public void Destroy() { MpeLog.Debug("MpeFont.Destroy()"); if (texture != null) { texture.Dispose(); } }
public MpeTextArea(MpeTextArea textarea) : base(textarea) { MpeLog.Debug("MpeTextArea(textarea)"); label = new MpeLabel(textarea.label); spinButton = new MpeSpinButton(textarea.spinButton); Controls.Add(label); Controls.Add(spinButton); }
public MpeScreen(MpeScreen window) : base(window) { MpeLog.Debug("MpeScreen(window)"); AllowDrop = true; allowOverlay = window.allowOverlay; defaultControl = window.defaultControl; screenSize = window.screenSize; }
public MpeToggleButton(MpeToggleButton button) : base(button) { MpeLog.Debug("MpeToggleButton(button)"); Init(); alternateTextureFocus = button.alternateTextureFocus; alternateTextureNoFocus = button.alternateTextureNoFocus; toggled = button.toggled; }
private void OnResourceListSelectionChanged(object sender, EventArgs e) { SelectedResource = (MpeResource)resourceList.SelectedItem; MpeLog.Debug("ResourceListSelectionChange = " + (SelectedResource != null ? SelectedResource.Id.ToString() : "null")); if (ResourceListSelectionChanged != null) { ResourceListSelectionChanged(SelectedResource); } }
public MpeButton(MpeButton button) : base(button) { MpeLog.Debug("MpeButton(button)"); Type = MpeControlType.Button; textureFocus = button.textureFocus; textureFocusImage = button.textureFocusImage; textureNoFocus = button.textureNoFocus; textureNoFocusImage = button.textureNoFocusImage; diffuseColor = button.diffuseColor; }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is String) { string s = (string)value; if (s.IndexOf(",") < 0) { try { int i = int.Parse(s); return(new MpeControlPadding(i)); } catch { MpeLog.Warn("Invalid format for padding property."); throw new ArgumentException("Invalid format for padding property [" + s + "]"); } } else { MpeControlPadding padding = new MpeControlPadding(); try { string[] ss = s.Split(','); if (ss == null || (ss.Length != 4 && ss.Length != 2)) { MpeLog.Warn("Invalid format for padding property [" + s + "]"); throw new ArgumentException("Invalid format for padding property [" + s + "]"); } if (ss.Length == 4) { padding.Left = int.Parse(ss[0].Trim()); padding.Right = int.Parse(ss[1].Trim()); padding.Top = int.Parse(ss[2].Trim()); padding.Bottom = int.Parse(ss[3].Trim()); } else { padding.Left = int.Parse(ss[0].Trim()); padding.Right = padding.Left; padding.Top = int.Parse(ss[1].Trim()); padding.Bottom = padding.Top; } return(padding); } catch (Exception ee) { MpeLog.Debug(ee); MpeLog.Warn("Invalid format for padding property [" + s + "]"); throw new ArgumentException("Invalid format for padding property [" + s + "]"); } } } return(base.ConvertFrom(context, culture, value)); }
public override void Load(XPathNodeIterator iterator, MpeParser parser) { MpeLog.Debug("MpeSelectButton.Load()"); base.Load(iterator, parser); this.parser = parser; // Regular Button Properties label.Load(iterator, parser); label.AutoSize = false; label.Size = new Size(parser.GetInt(iterator, "width", Width), parser.GetInt(iterator, "height", Height)); offset = new Point(parser.GetInt(iterator, "textXOff2", offset.X), parser.GetInt(iterator, "textYOff2", offset.Y)); TextureButton = parser.GetImageFile(iterator, "textureNoFocus", TextureButton); TextureButtonFocus = parser.GetImageFile(iterator, "textureFocus", TextureButton); tags.Remove("align"); tags.Remove("font"); tags.Remove("textcolor"); tags.Remove("disabledcolor"); tags.Remove("label"); tags.Remove("textXOff"); tags.Remove("textYOff"); tags.Remove("textureFocus"); tags.Remove("textureNoFocus"); // Select Button Properties int x = parser.GetInt(iterator, "textXOff", TexturePadding.Width); TextureSize = new Size(parser.GetInt(iterator, "textureWidth", textureSize.Width), parser.GetInt(iterator, "textureHeight", textureSize.Height)); TexturePadding = new MpeControlPadding(x / 2, (Height - textureSize.Height) / 2); TextureBackground = parser.GetImageFile(iterator, "texturebg", TextureBack); TextureLeft = parser.GetImageFile(iterator, "textureLeft", TextureLeft); TextureLeftFocus = parser.GetImageFile(iterator, "textureLeftFocus", TextureLeftFocus); TextureRight = parser.GetImageFile(iterator, "textureRight", TextureRight); TextureRightFocus = parser.GetImageFile(iterator, "textureRightFocus", TextureRightFocus); tags.Remove("texturebg"); tags.Remove("textureLeft"); tags.Remove("textureLeftFocus"); tags.Remove("textureRight"); tags.Remove("textureRightFocus"); tags.Remove("textureWidth"); tags.Remove("textureHeight"); tags.Remove("textXOff2"); tags.Remove("textYOff2"); // Get SubItems items.Values.Clear(); XPathNodeIterator i = iterator.Current.Select("subitems/subitem"); while (i.MoveNext()) { MpeItem item = new MpeItem(); item.Value = i.Current.Value; items.Values.Add(item); } Prepare(); Modified = false; }
public override void Load(XPathNodeIterator iterator, MpeParser parser) { MpeLog.Debug("MpeToggleButton.Load()"); base.Load(iterator, parser); this.parser = parser; AlternateTextureFocus = parser.GetImageFile(iterator, "AltTextureFocus", AlternateTextureFocus); AlternateTextureNoFocus = parser.GetImageFile(iterator, "AltTextureNoFocus", AlternateTextureNoFocus); tags.Remove("AltTextureFocus"); tags.Remove("AltTextureNoFocus"); Modified = false; }
public MpeImage() : base() { MpeLog.Debug("MpeImage()"); Type = MpeControlType.Image; textureFile = null; textureImage = null; keepAspectRatio = false; colorKey = 0; filtered = true; centered = false; }
protected override void PrepareControl() { if (label != null && imageGroup != null && imageUp != null && imageDown != null) { MpeLog.Debug("MpeSpinButton.Prepare()"); Controls.Clear(); imageGroup.Controls.Clear(); if (Orientation == MpeControlOrientation.Horizontal) { imageGroup.LayoutStyle = MpeLayoutStyle.HorizontalFlow; switch (Alignment) { case MpeControlAlignment.Left: imageGroup.Controls.Add(imageDown); imageGroup.Controls.Add(imageUp); Controls.Add(label); Controls.Add(imageGroup); break; case MpeControlAlignment.Center: Controls.Add(imageDown); Controls.Add(label); Controls.Add(imageUp); break; case MpeControlAlignment.Right: imageGroup.Controls.Add(imageDown); imageGroup.Controls.Add(imageUp); Controls.Add(imageGroup); Controls.Add(label); break; } } else { imageGroup.LayoutStyle = MpeLayoutStyle.VerticalFlow; imageGroup.Controls.Add(imageUp); imageGroup.Controls.Add(imageDown); switch (Alignment) { case MpeControlAlignment.Left: Controls.Add(label); Controls.Add(imageGroup); break; default: Controls.Add(imageGroup); Controls.Add(label); break; } } base.PrepareControl(); } }
public MpeImage(MpeImage image) : base(image) { MpeLog.Debug("MpeImage(image)"); textureFile = image.textureFile; textureImage = image.textureImage; keepAspectRatio = image.keepAspectRatio; centered = image.centered; filtered = image.filtered; colorKey = image.colorKey; diffuseColor = image.diffuseColor; }
public MpeCheckBox(MpeCheckBox checkbox) : base(checkbox) { MpeLog.Debug("MpeCheckBox(checkbox)"); Type = MpeControlType.CheckBox; AllowDrop = false; label = new MpeLabel(checkbox.label); image = new MpeImage(checkbox.image); textureFile = checkbox.textureFile; textureCheckedFile = checkbox.textureCheckedFile; Controls.Add(label); Controls.Add(image); }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { if (doc != null && node != null) { base.Save(doc, node, parser, reference); //parser.SetValue(doc, node, "animation", Animation.ToString()); XmlElement mpenode = doc.CreateElement("mpe"); node.AppendChild(mpenode); parser.SetValue(doc, mpenode, "layout", LayoutStyle.ToString()); parser.SetValue(doc, mpenode, "spring", Spring ? "yes" : "no"); parser.SetInt(doc, mpenode, "spacing", Spacing); parser.SetPadding(doc, mpenode, "padding", Padding); if (backImage != null && backImage.Texture != null) { XmlElement image = doc.CreateElement("control"); backImage.Location = AbsoluteLocation; backImage.Save(doc, image, parser, parser.GetControl(MpeControlType.Image)); backImage.Location = Point.Empty; node.AppendChild(image); } if (reference != null) { for (int i = Controls.Count - 1; i >= 0; i--) { if (Controls[i] is MpeControl) { MpeControl control = (MpeControl)Controls[i]; try { XmlElement element = doc.CreateElement("control"); MpeControl referenceControl = parser.GetControl(control.Type); control.Save(doc, element, parser, referenceControl); node.AppendChild(element); } catch (Exception e) { MpeLog.Debug(e); MpeLog.Error(e); throw new MpeParserException(e.Message); } } } } } }