コード例 #1
0
        private void ProcessButtonClick(object sender, SledReadOnlyDocResolutionFormOptions option)
        {
            var btn = (Button)sender;
            btn.Enabled = false;

            var ea =
                new SledReadOnlyDocResolutionFormEventArgs(m_sd, option);

            TryOptionEvent.Raise(this, ea);

            if (!ea.Result)
                return;

            m_bCanClose = true;
            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #2
0
        private void ProcessButtonClick(object sender, SledReadOnlyDocResolutionFormOptions option)
        {
            var btn = (Button)sender;

            btn.Enabled = false;

            var ea =
                new SledReadOnlyDocResolutionFormEventArgs(m_sd, option);

            TryOptionEvent.Raise(this, ea);

            if (!ea.Result)
            {
                return;
            }

            m_bCanClose  = true;
            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #3
0
        private void FormTryOptionEvent(object sender, SledReadOnlyDocResolutionFormEventArgs e)
        {
            var sd = e.SledDocument as SledDocument;

            if (sd == null)
            {
                return;
            }

            switch (e.Option)
            {
            case SledReadOnlyDocResolutionFormOptions.RemoveReadOnly:
            {
                e.Result = m_fileWatcherService.TryRemoveReadOnlyAttribute(sd);
                if (e.Result)
                {
                    sd.IsReadOnly = false;
                }
            }
            break;

            case SledReadOnlyDocResolutionFormOptions.RemoveReadOnlyAndSave:
            {
                e.Result = m_fileWatcherService.TryRemoveReadOnlyAttribute(sd);
                if (e.Result)
                {
                    sd.IsReadOnly = false;
                    m_documentService.Get.Save(e.SledDocument);
                }
            }
            break;

            case SledReadOnlyDocResolutionFormOptions.SaveAs:
            {
                //bool bOrigValue = sd.IsNew;

                //// Force so we can save-as
                //if (!bOrigValue)
                //    sd.IsNew = true;

                //// Try and save-as
                //e.Result = m_documentService.Get.SaveAs(sd);
                //if (e.Result)
                //    sd.ReadOnly = false;

                //// Failed to save-as so reset 'new' setting if it was changed
                //if (!e.Result)
                //    sd.IsNew = bOrigValue;
            }
            break;

            case SledReadOnlyDocResolutionFormOptions.UndoChanges:
            {
                // Reload the file and re-register control
                try
                {
                    sd.Read();
                    sd.IsReadOnly = true;
                    sd.Dirty      = false;
                    e.Result      = true;
                }
                catch (Exception)
                {
                    e.Result = false;
                }
            }
            break;

            default:
            {
                e.Result = false;
            }
            break;
            }
        }
コード例 #4
0
        private void FormTryOptionEvent(object sender, SledReadOnlyDocResolutionFormEventArgs e)
        {
            var sd = e.SledDocument as SledDocument;
            if (sd == null)
                return;

            switch (e.Option)
            {
                case SledReadOnlyDocResolutionFormOptions.RemoveReadOnly:
                {
                    e.Result = m_fileWatcherService.TryRemoveReadOnlyAttribute(sd);
                    if (e.Result)
                        sd.IsReadOnly = false;
                }
                break;

                case SledReadOnlyDocResolutionFormOptions.RemoveReadOnlyAndSave:
                {
                    e.Result = m_fileWatcherService.TryRemoveReadOnlyAttribute(sd);
                    if (e.Result)
                    {
                        sd.IsReadOnly = false;
                        m_documentService.Get.Save(e.SledDocument);
                    }
                }
                break;

                case SledReadOnlyDocResolutionFormOptions.SaveAs:
                {
                    //bool bOrigValue = sd.IsNew;

                    //// Force so we can save-as
                    //if (!bOrigValue)
                    //    sd.IsNew = true;

                    //// Try and save-as
                    //e.Result = m_documentService.Get.SaveAs(sd);
                    //if (e.Result)
                    //    sd.ReadOnly = false;

                    //// Failed to save-as so reset 'new' setting if it was changed
                    //if (!e.Result)
                    //    sd.IsNew = bOrigValue;
                }
                break;

                case SledReadOnlyDocResolutionFormOptions.UndoChanges:
                {
                    // Reload the file and re-register control
                    try
                    {
                        sd.Read();
                        sd.IsReadOnly = true;
                        sd.Dirty = false;
                        e.Result = true;
                    }
                    catch (Exception)
                    {
                        e.Result = false;
                    }
                }
                break;

                default:
                {
                    e.Result = false;
                }
                break;
            }
        }