예제 #1
0
파일: MainForm.cs 프로젝트: tyranid/canape
        private void NewDocument(bool fromTemplate)
        {
            if (!CheckDirtyFlag())
            {
                CANAPETemplate template = null;

                if (fromTemplate)
                {
                    using (SelectProjectTemplateForm frm = new SelectProjectTemplateForm())
                    {
                        if (frm.ShowDialog(this) == DialogResult.OK)
                        {
                            template = frm.Template;
                        }
                    }
                }

                CANAPEProject.New();
                InitializeTree();
                SetTitle(null);

                if (template != null)
                {
                    try
                    {
                        // Allow insecure load, if someone has added a template they could just add a plugin
                        CANAPEProject.Load(template.GetStream(), null, true, false);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, ex.Message, Properties.Resources.MessageBox_ErrorString,
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                IProxyClientFactory client = (IProxyClientFactory)GeneralUtils.StringToObject(Properties.Settings.Default.ProxyClient);
                if (client != null)
                {
                    try
                    {
                        CANAPEProject.CurrentProject.DefaultProxyClient = client;
                    }
                    catch (ArgumentException)
                    {
                        CANAPEProject.CurrentProject.DefaultProxyClient = new IpProxyClientFactory();
                    }
                }

                OnProjectChanged();
            }
        }
예제 #2
0
파일: MainForm.cs 프로젝트: michyer/canape
        private void NewDocument(bool fromTemplate)
        {
            if (!CheckDirtyFlag())
            {
                CANAPETemplate template = null;

                if (fromTemplate)
                {
                    using (SelectProjectTemplateForm frm = new SelectProjectTemplateForm())
                    {
                        if (frm.ShowDialog(this) == DialogResult.OK)
                        {
                            template = frm.Template;
                        }
                    }
                }

                CANAPEProject.New();
                InitializeTree();
                SetTitle(null);

                if (template != null)
                {
                    try
                    {
                        CANAPEProject.Load(template.GetStream(), null, true);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, ex.Message, Properties.Resources.MessageBox_ErrorString,
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                IProxyClientFactory client = (IProxyClientFactory)GeneralUtils.StringToObject(Properties.Settings.Default.ProxyClient);
                if (client != null)
                {
                    try
                    {
                        CANAPEProject.CurrentProject.DefaultProxyClient = client;
                    }
                    catch (ArgumentException)
                    {
                        CANAPEProject.CurrentProject.DefaultProxyClient = new IpProxyClientFactory();
                    }
                }

                OnProjectChanged();
            }
        }