Ejemplo n.º 1
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            CElement el = getSelectedElement();
            WElement ct = getSelectedElementControl();

            if (el != null)
            {
                CropTexture Frmct = new CropTexture(el);
                if (Frmct.ShowDialog() == true)
                {
                    int    x   = Convert.ToInt32(Canvas.GetLeft(Frmct.rect));
                    int    y   = Convert.ToInt32(Canvas.GetTop(Frmct.rect));
                    int    x1  = Convert.ToInt32(x + Frmct.rect.Width);
                    int    y1  = Convert.ToInt32(y + Frmct.rect.Height);
                    WPoint uv1 = new WPoint(x, y);
                    WPoint uv2 = new WPoint(x1, y1);
                    el.SetUV(uv1, uv2);
                    el.Texture                   = Frmct.SelectedTexture.Name;
                    ct.Source                    = el.getImage();
                    pictureBox1.Source           = ct.Source;
                    _propertyGrid.SelectedObject = el.Properties.Properties;
                    _propertyGrid.Update();
                }
            }
        }
Ejemplo n.º 2
0
        public void SetSelectedElement(int ID)
        {
            if (ID != -1)
            {
                for (int i = 0; i < elements.Count; i++)
                {
                    elements[i].Selected = false;
                    getElementControl(elements[i].ID).setSelected(false);
                }

                CElement el = elements.getID(ID);
                el.Selected = true;

                pictureBox1.Source = el.getImage();
                getSelectedElementControl().BringIntoView();
                _propertyGrid.SelectedObject = getSelectedElement().Properties.Properties;

                getSelectedElementControl().setSelected(true);
                Panel.SetZIndex(getSelectedElementControl(), ZIndex++);
            }
            else
            { // seçimi kaldır
                for (int i = 0; i < elements.Count; i++)
                {
                    elements[i].Selected = false;
                    getElementControl(elements[i].ID).setSelected(false);
                }
            }
        }
Ejemplo n.º 3
0
        private void Panel1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.IsDown && e.Key == Key.D && Keyboard.Modifiers == ModifierKeys.Control)
            {
                CElement el = getSelectedElement();
                if (el != null)
                {
                    CElement nw = el.Clone();
                    nw.ID = UniqueID++;
                    nw.setLeft(nw.getLeft() + 10);
                    nw.setTop(nw.getTop() + 10);
                    elements.Add(nw);
                    WElement cnw = addElementControl(nw);
                    Panel.SetZIndex(cnw, panel1.zindex++);
                    SetSelectedElement(cnw.ElementID);

                    lwElementList.Items.Add(nw);

                    for (int i = 0; i < lwElementList.Items.Count; i++)
                    {
                        if (((CElement)lwElementList.Items[i]).ID == cnw.ElementID)
                        {
                            lwElementList.SelectedIndex = i;
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
 private void lwElementList_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (lwElementList.SelectedItems.Count == 1)
     {
         CElement el = getSelectedElement();
         SetSelectedElement(el.ID);
     }
 }
Ejemplo n.º 5
0
        private void Panel1_OnChangeElement(int ID, Point rec1, Point rec2)
        {
            CElement el = elements.getID(ID);

            if (el != null)
            {
                el.setRect(rec1, rec2);
                _propertyGrid.Update();
            }
        }
Ejemplo n.º 6
0
 public CropTexture(CElement el)
 {
     InitializeComponent();
     this.image.Source = el.getTexture().img;
     Canvas.SetLeft(rect, el.UV1.X);
     Canvas.SetTop(rect, el.UV1.Y);
     rect.Width           = el.UV2.X - el.UV1.X;
     rect.Height          = el.UV2.Y - el.UV1.Y;
     this.SelectedTexture = el.getTexture();
     RefCropImage();
 }
Ejemplo n.º 7
0
        public void updateElementControl(int ID)
        {
            WElement ct = getElementControl(ID);
            CElement el = elements.getID(ID);

            if (ct == null || el == null)
            {
                return;
            }

            ct.Width  = el.getWidth();
            ct.Height = el.getHeight();
            Canvas.SetLeft(ct, el.getLeft());
            Canvas.SetTop(ct, el.getTop());
            ct.Source = el.getImage();
        }
Ejemplo n.º 8
0
        public WElement getSelectedElementControl()
        {
            CElement el = getSelectedElement();

            if (el == null)
            {
                return(null);
            }
            for (int i = 0; i < panel1.Children.Count; i++)
            {
                if (((WElement)panel1.Children[i]).ElementID == el.ID)
                {
                    return((WElement)panel1.Children[i]);
                }
            }
            return(null);
        }
Ejemplo n.º 9
0
        public CElement Clone()
        {
            CElement don = new CElement();

            don.ID         = ID;
            don.Type       = Type;
            don.Name       = Name;
            don.Texture    = Texture;
            don.Group      = Group;
            don.Layer      = Layer;
            don.UV1        = UV1;
            don.UV2        = UV2;
            don.Rect1      = Rect1;
            don.Rect2      = Rect2;
            don.Selected   = Selected;
            don.FileName   = FileName;
            don.Properties = Properties;
            don.OLDTexture = OLDTexture;

            return(don);
        }
Ejemplo n.º 10
0
        public WElement addElementControl(CElement item)
        {
            WElement pc = new WElement();

            pc.ElementID = item.ID;
            Canvas.SetLeft(pc, item.getLeft());
            Canvas.SetTop(pc, item.getTop());
            pc.Stretch = Stretch.Fill;

            try
            {
                pc.Width  = item.getWidth();
                pc.Height = item.getHeight();
            }
            catch (Exception)
            {
            }
            pc.Source      = item.getImage();
            pc.ElementName = item.Name;
            pc.Tip         = item.Type == "Text" ? WElement.ETip.Text : WElement.ETip.Icon;
            if (item.Properties.exist("Size"))
            {
                pc.Size = Convert.ToInt32(item.Properties.getVal("Size").ToString());
            }
            else
            {
                pc.Size = 10;
            }
            if (item.Properties.exist("Color"))
            {
                pc.TColor = item.Properties.getVal("Color").ToString();
            }

            panel1.Children.Add(pc);

            return(pc);
        }
Ejemplo n.º 11
0
        internal void onPropertyChanged(CustomProperty _owner, object value)
        {
            WElement wc = getSelectedElementControl();
            CElement el = getSelectedElement();

            if (wc == null)
            {
                return;
            }

            if (_owner.Name.Trim().ToLower() == "visible" && _owner.WProp)
            {
                wc.Visibility = (bool)value == true ? Visibility.Visible : Visibility.Hidden;
            }

            if (_owner.WProp && _owner.Category.Trim().ToLower() == "rect")
            {
                if (_owner.Name.Trim() == "Width")
                {
                    el.setWidth((int)value);
                }
                if (_owner.Name.Trim() == "Height")
                {
                    el.setHeight((int)value);
                }
                if (_owner.Name.Trim() == "Left")
                {
                    el.setLeft((int)value);
                }
                if (_owner.Name.Trim() == "Top")
                {
                    el.setTop((int)value);
                }

                updateElementControl(el.ID);
            }
        }
Ejemplo n.º 12
0
        public void LoadElements(string inicontent)
        {
            elements.Clear();
            string[] lns = inicontent.Split(new string[] { "\r\n" }, StringSplitOptions.None);
            CElement el  = null;

            foreach (var line in lns)
            {
                if (line.Split(':').Length == 2)
                {
                    string key = line.Split(':')[0];
                    string val = line.Split(':')[1];
                    if (key.Trim() == "Type")
                    {
                        el      = new CElement();
                        el.ID   = UniqueID++;
                        el.Type = val.Trim();

                        if (((WorkPath)comboBox1.SelectedItem).OverrideOldTexture)
                        {
                            el.OLDTexture = true;
                        }
                    }

                    if (key.Trim() == "Name")
                    {
                        el.Name = val;
                    }
                    if (key.Trim() == "Group")
                    {
                        el.Group = val;
                    }
                    if (key.Trim() == "Texture")
                    {
                        el.Texture = val;
                    }
                    if (key.Trim() == "Layer")
                    {
                        el.Layer = Convert.ToSingle(val);
                    }

                    if (key.Trim() == "UV")
                    {
                        string cords1 = val.Split('/')[0].Split('-')[0];
                        string cords2 = val.Split('/')[0].Split('-')[1];
                        int    x1     = Convert.ToInt32(cords1.Split(',')[0]);
                        int    y1     = Convert.ToInt32(cords1.Split(',')[1]);
                        int    x2     = Convert.ToInt32(cords2.Split(',')[0]);
                        int    y2     = Convert.ToInt32(cords2.Split(',')[1]);
                        el.UV1 = new WPoint(x1, y1);
                        el.UV2 = new WPoint(x2, y2);

                        el.Properties.Add(new CustomProperty()
                        {
                            Name = "Image-Width", Category = "UV", Type = typeof(int), Value = x2 - x1, WProp = true
                        });
                        el.Properties.Add(new CustomProperty()
                        {
                            Name = "Image-Height", Category = "UV", Type = typeof(int), Value = y2 - y1, WProp = true
                        });
                    }

                    if (key.Trim() == "Rect")
                    {
                        string cords1 = val.Split('/')[0].Split(new string[] { " - " }, StringSplitOptions.None)[0];
                        string cords2 = val.Split('/')[0].Split(new string[] { " - " }, StringSplitOptions.None)[1];
                        int    x1     = Convert.ToInt32(Convert.ToSingle(cords1.Split(',')[0].Replace(".", ",")));
                        int    y1     = Convert.ToInt32(Convert.ToSingle(cords1.Split(',')[1].Replace(".", ",")));
                        int    x2     = Convert.ToInt32(Convert.ToSingle(cords2.Split(',')[0].Replace(".", ",")));
                        int    y2     = Convert.ToInt32(Convert.ToSingle(cords2.Split(',')[1].Replace(".", ",")));
                        el.Rect1 = new WPoint(x1, y1);
                        el.Rect2 = new WPoint(x2, y2);

                        //Propertye Rect düzenlemelerini gir
                        el.Properties.Add(new CustomProperty()
                        {
                            Name = "Visible", Category = "Rect", Type = typeof(bool), Value = true, WProp = true
                        });
                        el.Properties.Add(new CustomProperty()
                        {
                            Name = "Left", Category = "Rect", Type = typeof(int), Value = x1, WProp = true
                        });
                        el.Properties.Add(new CustomProperty()
                        {
                            Name = "Top", Category = "Rect", Type = typeof(int), Value = y1, WProp = true
                        });
                        el.Properties.Add(new CustomProperty()
                        {
                            Name = "Width", Category = "Rect", Type = typeof(int), Value = x2 - x1, WProp = true
                        });
                        el.Properties.Add(new CustomProperty()
                        {
                            Name = "Height", Category = "Rect", Type = typeof(int), Value = y2 - y1, WProp = true
                        });
                    }

                    if (el != null)
                    {
                        //el.props.Add(key, val);
                        Type tip     = typeof(string);
                        bool readonl = false;
                        if (key.Trim() == "UV")
                        {
                            readonl = true;
                        }
                        if (key.Trim() == "Rect")
                        {
                            readonl = true;
                        }
                        el.Properties.Add(new CustomProperty()
                        {
                            Name = key, ReadOnly = readonl, Category = "Other", Type = tip, Value = val
                        });
                    }
                }
                else if (line.StartsWith("///"))
                {
                    if (el != null)
                    {
                        elements.Add(el);
                        el = null;
                    }
                }
            }

            lwElementList.Items.Clear();
            foreach (var item in elements)
            {
                lwElementList.Items.Add(item);
            }

            RenderElements();
        }
Ejemplo n.º 13
0
        public void addBack(string fileName, bool oldTexture = false)
        {
            string iniContent = File.ReadAllText(fileName);
            int    ids        = 1;

            string[] lns = iniContent.Split(new string[] { "\r\n" }, StringSplitOptions.None);
            CElement el  = null;

            foreach (var line in lns)
            {
                if (line.Split(':').Length == 2)
                {
                    string key = line.Split(':')[0];
                    string val = line.Split(':')[1];
                    if (key.Trim() == "Type")
                    {
                        el            = new CElement();
                        el.ID         = ids++;
                        el.Type       = val.Trim();
                        el.FileName   = fileName;
                        el.OLDTexture = oldTexture;
                    }

                    if (key.Trim() == "Name")
                    {
                        el.Name = val;
                    }
                    if (key.Trim() == "Group")
                    {
                        el.Group = val;
                    }
                    if (key.Trim() == "Texture")
                    {
                        el.Texture = val;
                    }
                    if (key.Trim() == "Layer")
                    {
                        el.Layer = Convert.ToSingle(val);
                    }

                    if (key.Trim() == "UV")
                    {
                        string cords1 = val.Split('/')[0].Split('-')[0];
                        string cords2 = val.Split('/')[0].Split('-')[1];
                        int    x1     = Convert.ToInt32(cords1.Split(',')[0]);
                        int    y1     = Convert.ToInt32(cords1.Split(',')[1]);
                        int    x2     = Convert.ToInt32(cords2.Split(',')[0]);
                        int    y2     = Convert.ToInt32(cords2.Split(',')[1]);
                        el.UV1 = new WPoint(x1, y1);
                        el.UV2 = new WPoint(x2, y2);

                        el.Properties.Add(new CustomProperty()
                        {
                            Name = "Image-Width", Category = "UV", Type = typeof(int), Value = x2 - x1, WProp = true
                        });
                        el.Properties.Add(new CustomProperty()
                        {
                            Name = "Image-Height", Category = "UV", Type = typeof(int), Value = y2 - y1, WProp = true
                        });
                    }

                    if (key.Trim() == "Rect")
                    {
                        string cords1 = val.Split('/')[0].Split(new string[] { " - " }, StringSplitOptions.None)[0];
                        string cords2 = val.Split('/')[0].Split(new string[] { " - " }, StringSplitOptions.None)[1];
                        int    x1     = Convert.ToInt32(Convert.ToSingle(cords1.Split(',')[0].Replace(".", ",")));
                        int    y1     = Convert.ToInt32(Convert.ToSingle(cords1.Split(',')[1].Replace(".", ",")));
                        int    x2     = Convert.ToInt32(Convert.ToSingle(cords2.Split(',')[0].Replace(".", ",")));
                        int    y2     = Convert.ToInt32(Convert.ToSingle(cords2.Split(',')[1].Replace(".", ",")));
                        el.Rect1 = new WPoint(x1, y1);
                        el.Rect2 = new WPoint(x2, y2);

                        //Propertye Rect düzenlemelerini gir
                        el.Properties.Add(new CustomProperty()
                        {
                            Name = "Left", Category = "Rect", Type = typeof(int), Value = x1, WProp = true
                        });
                        el.Properties.Add(new CustomProperty()
                        {
                            Name = "Top", Category = "Rect", Type = typeof(int), Value = y1, WProp = true
                        });
                        el.Properties.Add(new CustomProperty()
                        {
                            Name = "Height", Category = "Rect", Type = typeof(int), Value = x2 - x1, WProp = true
                        });
                        el.Properties.Add(new CustomProperty()
                        {
                            Name = "Width", Category = "Rect", Type = typeof(int), Value = y2 - y1, WProp = true
                        });
                    }

                    if (el != null)
                    {
                        //el.props.Add(key, val);
                        Type tip     = typeof(string);
                        bool readonl = false;
                        if (key.Trim() == "UV")
                        {
                            readonl = true;
                        }
                        if (key.Trim() == "Rect")
                        {
                            readonl = true;
                        }
                        el.Properties.Add(new CustomProperty()
                        {
                            Name = key, ReadOnly = readonl, Category = "Other", Type = tip, Value = val
                        });
                    }
                }
                else if (line.StartsWith("///"))
                {
                    if (el != null)
                    {
                        backElements.Add(el);
                        el = null;
                    }
                }
            }

            renderBackground();
        }