コード例 #1
0
ファイル: EditTrail.cs プロジェクト: tsofron/trails
        private EditTrail(bool addMode, bool copyMode)
        {
            this.m_addMode = addMode;

            InitializeComponent();

            if (Controller.TrailController.Instance.PrimaryCurrentActivityTrail == null)
            {
                this.m_addMode = true;
                copyMode       = false;
            }

            if (this.m_addMode && !copyMode)
            {
                //new empty trail
                this.m_TrailToEdit = new TrailsPlugin.Data.Trail();
            }
            else
            {
                Trail trail = Controller.TrailController.Instance.PrimaryCurrentActivityTrail.Trail;
                if (copyMode || trail.Generated)
                {
                    //Add a copy of the trail from the (reference) activity
                    IActivity activity = Controller.TrailController.Instance.ReferenceActivity;
                    this.m_TrailToEdit = trail.Copy(activity, this.m_addMode);
                }
                else
                {
                    //Make a copy (with same Guid) of current, so changes can be undone
                    this.m_TrailToEdit = trail.Duplicate();
                }
            }

            if (this.m_addMode)
            {
                this.Name = Properties.Resources.UI_Activity_EditTrail_AddTrail;
            }
            else
            {
                this.Name = Properties.Resources.UI_Activity_EditTrail_EditTrail;
            }
            this.Text = this.Name;
            //Done after init code, as it depends on it
            this.InitControls();
        }