Example #1
0
        /// <summary>
        /// Doubleclick Node of Import treeview
        /// </summary>
        private void treeViewMultiList_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Node.Tag == null)
                return;

            switch (e.Node.Tag.ToString())
            {
                case "txt": treeViewMultiList_LoadFromFile(Multis.ImportType.TXT); return;
                case "uoa": treeViewMultiList_LoadFromFile(Multis.ImportType.UOA); return;
                case "uoab": treeViewMultiList_LoadFromFile(Multis.ImportType.UOAB); return;
                case "wsc": treeViewMultiList_LoadFromFile(Multis.ImportType.WSC); return;
                case "cache": treeViewMultiList_LoadFromFile(Multis.ImportType.MULTICACHE); return;
                case "uoadesign": treeViewMultiList_LoadFromFile(Multis.ImportType.UOADESIGN); return;
                default: break;
            }

            if (MessageBox.Show("Do you want to open selected Multi?", "Open", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.OK)
            {
                if ((e.Node.Parent != null) && (e.Node.Parent.Tag != null) && (e.Node.Parent.Tag.ToString() == "cache"))
                {
                    MultiComponentList list = (MultiComponentList)e.Node.Tag;
                    if (list != null)
                    {
                        compList = new MultiEditorComponentList(list, this);
                        textBox_SaveToID.Text = "0";
                    }
                }
                else if ((e.Node.Parent != null) && (e.Node.Parent.Tag != null) && (e.Node.Parent.Tag.ToString() == "uoadesign"))
                {
                    MultiComponentList list = (MultiComponentList)e.Node.Tag;
                    if (list != null)
                    {
                        compList = new MultiEditorComponentList(list, this);
                        textBox_SaveToID.Text = "0";
                    }
                }
                else
                {
                    compList = new MultiEditorComponentList(Ultima.Multis.GetComponents((int)e.Node.Tag), this);
                    textBox_SaveToID.Text = e.Node.Tag.ToString();
                }
                UndoList_Clear();
                MaxHeightTrackBar.Minimum = compList.zMin;
                MaxHeightTrackBar.Maximum = compList.zMax;
                MaxHeightTrackBar.Value = compList.zMax;
                numericUpDown_Size_Width.Value = compList.Width;
                numericUpDown_Size_Height.Value = compList.Height;
                numericUpDown_Selected_X.Maximum = compList.Width - 1;
                numericUpDown_Selected_Y.Maximum = compList.Height - 1;
                vScrollBar.Value = 0;
                hScrollBar.Value = 0;
                ScrollbarsSetValue();
                ForceRefresh = true;
                pictureBoxMulti.Invalidate();
            }
        }
Example #2
0
 // Private Methods (35)
 /// <summary>
 /// Creates new blank Multi
 /// </summary>
 private void BTN_CreateBlank_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Do you want to create a blank Multi?", "Create", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.OK)
     {
         int width = (int)numericUpDown_Size_Width.Value;
         int height = (int)numericUpDown_Size_Height.Value;
         compList = new MultiEditorComponentList(width, height, this);
         UndoList_Clear();
         MaxHeightTrackBar.Minimum = compList.zMin;
         MaxHeightTrackBar.Maximum = compList.zMax;
         MaxHeightTrackBar.Value = compList.zMax;
         numericUpDown_Selected_X.Maximum = compList.Width - 1;
         numericUpDown_Selected_Y.Maximum = compList.Height - 1;
         ScrollbarsSetValue();
         ForceRefresh = true;
         pictureBoxMulti.Invalidate();
     }
 }
Example #3
0
 private void treeViewMultiList_LoadFromFile(Multis.ImportType importtype)
 {
     OpenFileDialog dialog = new OpenFileDialog();
     dialog.Multiselect = false;
     string type = "";
     switch (importtype)
     {
         case Multis.ImportType.TXT: type = "txt"; break;
         case Multis.ImportType.UOA: type = "uoa"; break;
         case Multis.ImportType.UOAB: type = "uoab"; break;
         case Multis.ImportType.WSC: type = "wsc"; break;
         case Multis.ImportType.MULTICACHE: type = "Multicache.dat"; break;
         case Multis.ImportType.UOADESIGN: type = "Designs"; break;
         default: return;
     }
     dialog.Title = String.Format("Choose {0} file to import", type);
     dialog.CheckFileExists = true;
     if (importtype == Multis.ImportType.MULTICACHE)
         dialog.Filter = String.Format("{0} file ({0})|{0}", type);
     else if (importtype == Multis.ImportType.UOADESIGN)
         dialog.Filter = String.Format("{0} file ({0}.*)|{0}.*", type);
     else if (importtype == Multis.ImportType.UOAB)
         dialog.Filter = String.Format("{0} file (*.{0})|*.{0}", "uoa");
     else
         dialog.Filter = String.Format("{0} file (*.{0})|*.{0}", type);
     if (dialog.ShowDialog() == DialogResult.OK)
     {
         if (importtype == Multis.ImportType.MULTICACHE)
         {
             List<MultiComponentList> list = Ultima.Multis.LoadFromCache(dialog.FileName);
             TreeNode node = treeViewMultiList.Nodes[1].Nodes[4];
             node.Nodes.Clear();
             for (int i = 0; i < list.Count; ++i)
             {
                 TreeNode child = new TreeNode("Entry " + i);
                 child.Tag = list[i];
                 node.Nodes.Add(child);
             }
         }
         else if (importtype == Multis.ImportType.UOADESIGN)
         {
             List<Object[]> list = Ultima.Multis.LoadFromDesigner(dialog.FileName);
             TreeNode node = treeViewMultiList.Nodes[1].Nodes[5];
             node.Nodes.Clear();
             for (int i = 0; i < list.Count; ++i)
             {
                 Object[] data = list[i];
                 TreeNode child = new TreeNode(data[0] + "(" + i + ")");
                 child.Tag = data[1];
                 node.Nodes.Add(child);
             }
         }
         else
         {
             MultiComponentList multi = Ultima.Multis.LoadFromFile(dialog.FileName, importtype);
             compList = new MultiEditorComponentList(multi, this);
             UndoList_Clear();
             MaxHeightTrackBar.Minimum = compList.zMin;
             MaxHeightTrackBar.Maximum = compList.zMax;
             MaxHeightTrackBar.Value = compList.zMax;
             textBox_SaveToID.Text = "0";
             numericUpDown_Size_Width.Value = compList.Width;
             numericUpDown_Size_Height.Value = compList.Height;
             numericUpDown_Selected_X.Maximum = compList.Width - 1;
             numericUpDown_Selected_Y.Maximum = compList.Height - 1;
             vScrollBar.Value = 0;
             hScrollBar.Value = 0;
             ScrollbarsSetValue();
             ForceRefresh = true;
             pictureBoxMulti.Invalidate();
         }
     }
     dialog.Dispose();
 }