Ejemplo n.º 1
0
        private void Delete()
        {
            SuitSchemeItemCollection items = new SuitSchemeItemCollection();

            axSuitSchemeView1.SelectedItems(items);
            foreach (SchemeItem item in items)
            {
                axSuitSchemeView1.Remove(item.Name);
            }
        }
Ejemplo n.º 2
0
        private void UnLocked()
        {
            SuitSchemeItemCollection items = new SuitSchemeItemCollection();

            axSuitSchemeView1.SelectedItems(items);
            foreach (SchemeItem item in items)
            {
                axSuitSchemeView1.Locked(item.Name, true);
            }
        }
Ejemplo n.º 3
0
        void button_Click(object sender, EventArgs e)
        {
            switch (((ToolStripItem)sender).Text)
            {
            case "关闭":
                this.Close();
                break;

            case "打开":
                //OpenExist();
                break;

            case "保存":
                Core.ToolTip tip = new UnvaryingSagacity.Core.ToolTip();
                tip.ShowPrompt(this, "正在保存票证设计......");
                this.Cursor = Cursors.WaitCursor;
                BeforeSave();

                Core.XmlSerializer <SchemeSerialization> .ToXmlSerializer(CurrentEnvironment.AccountCoverFilename, CurrentScheme);

                tip.Hide();
                this.Cursor = Cursors.Default;
                break;

            case "更换底图":
                //Image image = _environment.ShowImageCollectionDialog(this, this._environment.MainUIClientBounds);
                //if (image != null)
                //{
                //    CurrentScheme.BackgroundImage = image;
                //    axSuitSchemeView1.SchemeItemParent.BackgroundImage = image;
                //    axSuitSchemeView1.RedrawSchemeBackgroundImage();
                //}
                break;

            case "新增":
                CreateItem();
                break;

            case "手绘模式":
                if (((ToolStripButton)sender).Checked)
                {
                    axSuitSchemeView1.HandleDrawMode = true;
                    axSuitSchemeView1.Cursor         = Cursors.Cross;
                    toolStrip2.Enabled = false;
                }
                else
                {
                    axSuitSchemeView1.HandleDrawMode = false;
                    axSuitSchemeView1.Cursor         = Cursors.Default;
                    toolStrip2.Enabled = true;
                }
                break;

            case "复制":
                SuitSchemeItemCollection items = new SuitSchemeItemCollection();
                axSuitSchemeView1.SelectedItems(items);
                if (items.Count > 1)
                {
                    SchemeSerialization scheme = new SchemeSerialization();
                    foreach (SchemeItem item in items)
                    {
                        SchemeItemSerialization dst = new SchemeItemSerialization();
                        item.Clone(dst);
                        scheme.Items.Add(dst);
                    }
                    scheme.SyncItemsFromBase();
                    System.IO.MemoryStream m = new System.IO.MemoryStream();
                    Core.XmlSerializer <SchemeSerialization> .ToXmlSerializer(m, scheme);

                    Core.XmlSerializer <SchemeSerialization> .ToXmlSerializer(@"C:\aaa.txt", scheme);

                    byte[] readByte   = m.ToArray();
                    string readString = Encoding.UTF8.GetString(readByte, 0, readByte.Length);
                    Clipboard.SetText("SchemeItems:" + readString, TextDataFormat.UnicodeText);
                }
                else
                {
                    if (axSuitSchemeView1.ActivedSchemeItem != null)
                    {
                        SchemeItemSerialization dst = new SchemeItemSerialization();
                        axSuitSchemeView1.ActivedSchemeItem.Clone(dst);
                        System.IO.MemoryStream m = new System.IO.MemoryStream();
                        Core.XmlSerializer <SchemeItemSerialization> .ToXmlSerializer(m, dst);

                        //Core.XmlSerializer<SchemeItemSerialization>.ToXmlSerializer(@"C:\aaa.txt", dst);

                        byte[] readByte   = m.ToArray();
                        string readString = Encoding.UTF8.GetString(readByte, 0, readByte.Length);
                        Clipboard.SetText("SchemeItem:" + readString, TextDataFormat.UnicodeText);
                    }
                }
                break;

            case "粘贴":
                string s = Clipboard.GetText(TextDataFormat.UnicodeText);
                if (s.IndexOf("SchemeItem:") == 0)
                {
                    s = s.Substring("SchemeItem:".Length);
                    byte[] b = Encoding.Unicode.GetBytes(s);
                    System.IO.MemoryStream  m = new System.IO.MemoryStream(b, 0, b.Length);
                    SchemeItemSerialization o = new SchemeItemSerialization();
                    if (Core.XmlSerializer <SchemeItemSerialization> .FromXmlSerializer(m, out o))
                    {
                        SchemeItem item = new SchemeItem();
                        o.Copy(item);
                        item.Name = axSuitSchemeView1.GetUniqueName(o.Name);
                        axSuitSchemeView1.Add(item);
                        axSuitSchemeView1.AxSchemeItemBringToFront(item.Name, true);
                    }
                }
                else if (s.IndexOf("SchemeItems:") == 0)
                {
                    s = s.Substring("SchemeItems:".Length);
                    byte[] b = Encoding.Unicode.GetBytes(s);
                    System.IO.MemoryStream m        = new System.IO.MemoryStream(b, 0, b.Length);
                    SchemeSerialization    dstItems = new SchemeSerialization();
                    if (Core.XmlSerializer <SchemeSerialization> .FromXmlSerializer(m, out dstItems))
                    {
                        dstItems.SyncItemsToBase();
                        foreach (SchemeItem o in dstItems.Items)
                        {
                            SchemeItem item = new SchemeItem();
                            o.Copy(item);
                            item.Name = axSuitSchemeView1.GetUniqueName(o.Name);
                            axSuitSchemeView1.Add(item);
                            axSuitSchemeView1.AxSchemeItemBringToFront(item.Name, true);
                        }
                    }
                }
                break;

            case "删除":
                if (MessageBox.Show(this, "您确定要删除选中的打印项吗?", "删除打印项", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Delete();
                }
                break;

            case "锁定":
                Locked();
                break;

            case "解锁":
                UnLocked();
                break;

            case "打印":
                break;

            case "打印设置":
                BeforeSave();
                CurrentEnvironment.ShowPrintSettingsDialog(this, CurrentScheme);
                break;

            case "有票样图的预览":
                break;

            case "预览":
                BeforeSave();
                SetVisualValue(CurrentScheme);
                CurrentEnvironment.PrintScheme(this, CurrentScheme, true, false, false);
                break;

            case "移动...":
                break;

            case "格式刷":
                axSuitSchemeView1.Cursor = Cursors.Default;
                if (this.toolStripButton6.Checked)
                {
                    this.toolStripButton6.Tag     = null;
                    this.toolStripButton6.Checked = false;
                }
                else
                {
                    if (axSuitSchemeView1.ActivedSchemeItem != null)
                    {
                        SchemeItem formatItem = new SchemeItem();
                        axSuitSchemeView1.ActivedSchemeItem.Clone(formatItem);
                        this.toolStripButton6.Tag     = formatItem;
                        this.toolStripButton6.Checked = true;
                        axSuitSchemeView1.Cursor      = Cursors.Hand;
                    }
                }
                break;

            case "使大小相同":
                SameSize(0);
                break;

            case "使高度相同":
                SameSize(2);
                break;

            case "使宽度相同":
                SameSize(1);
                break;

            case "底对齐":
                SameLocation(5);
                break;

            case "垂直中间对齐":
                SameLocation(6);
                break;

            case "顶对齐":
                SameLocation(4);
                break;

            case "右对齐":
                SameLocation(2);
                break;

            case "水平中间对齐":
                SameLocation(3);
                break;

            case "左对齐":
                SameLocation(1);
                break;

            case "全选":
                axSuitSchemeView1.SelectAll();
                break;

            case "使用底图尺寸":
                if (CurrentScheme.BackgroundImage != null)
                {
                    float w         = (CurrentScheme.BackgroundImage.Width / (AxSuitSchemeView.MMTOINCH * CurrentScheme.DpiX));
                    float h         = (CurrentScheme.BackgroundImage.Height / (AxSuitSchemeView.MMTOINCH * CurrentScheme.DpiY));
                    Size  imageSize = new Size((int)Math.Round(w, 0), (int)(Math.Round(h, 0)));
                    CurrentScheme.Size = imageSize;
                    axSuitSchemeView1.SchemeItemParent.Size = CurrentScheme.Size;
                    axSuitSchemeView1.RedrawSchemeBackgroundImage();
                }
                break;

            case "封面尺寸":
                Core.InputBox input = new InputBox("输入封面尺寸", "请准确输入封面的宽和高并用逗号(或非数字字符)分隔\n注意单位是毫米", 7, CurrentScheme.Size.Width + "," + CurrentScheme.Size.Height);
                if (input.ShowDialog(this) == DialogResult.OK)
                {
                    string sz = input.Result.ToString();
                    if (sz.Length < 0)
                    {
                        return;
                    }
                    if (sz == CurrentScheme.Size.Width + "," + CurrentScheme.Size.Height)
                    {
                        return;
                    }
                    int           w  = 0;
                    int           h  = 0;
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < sz.Length; i++)
                    {
                        string c = sz.Substring(i, 1);
                        if (Core.General.IsNumberic(c, false, false))
                        {
                            sb.Append(c);
                        }
                        else
                        {
                            if (sb.Length > 0 && w == 0)
                            {
                                w = int.Parse(sb.ToString());
                                sb.Remove(0, sb.Length);
                            }
                        }
                    }
                    if (sb.Length > 0 && h == 0)
                    {
                        h = int.Parse(sb.ToString());
                    }
                    if (w > 0 && h > 0)
                    {
                        if (MessageBox.Show(this, "您确定新的票证尺寸为: " + w + "," + h + " 毫米吗?", "票证尺寸", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                        {
                            CurrentScheme.Size = new Size(w, h);
                            axSuitSchemeView1.SchemeItemParent.Size = new Size(w, h);
                            axSuitSchemeView1.RedrawSchemeBackgroundImage();
                        }
                    }
                }
                break;

            case "清除水平间距":
                ChangSpaceH(0);
                break;

            case "增加水平间距":
                ChangSpaceH(1);
                break;

            case "减少水平间距":
                ChangSpaceH(-1);
                break;

            case "清除垂直间距":
                ChangSpaceV(0);
                break;

            case "增加垂直间距":
                ChangSpaceV(1);
                break;

            case "减少垂直间距":
                ChangSpaceV(-1);
                break;

            default:
                break;
            }
        }