Exemplo n.º 1
0
        public static void ResizeColumn(Panel panel, bool right)
        {
            if (panel == null) throw new ArgumentNullException("panel");

            var view = panel.ViewMode;
            var plan = panel.GetPlan(view) ?? panel.ViewPlan;
            if (plan.Columns.Length != 2)
                return;

            int width = panel.Window.Width - 2;
            plan.Columns[0].Width = 0;
            if (plan.Columns[1].Width == 0)
                plan.Columns[1].Width = width / 2;

            int width2 = plan.Columns[1].Width;
            if (right)
            {
                --width2;
                if (width2 < 1)
                    return;
            }
            else
            {
                ++width2;
                if (width2 > width - 2)
                    return;
            }

            plan.Columns[1].Width = width2;
            panel.SetPlan(view, plan);
            panel.Redraw();
        }
Exemplo n.º 2
0
        protected override void ProcessRecord()
        {
            // ignore empty or the rest of input
            if (InputObject == null || _Panel != null)
                return;

            // get the panel or a new member panel
            var explorer = InputObject.BaseObject as Explorer;
            if (explorer == null)
                _Panel = (InputObject.BaseObject as Panel) ?? new MemberPanel(new MemberExplorer(InputObject));
            else
                _Panel = explorer.CreatePanel();

            // setup and show
            ApplyParameters(_Panel);
            _Panel.Open(AsChild);
        }
Exemplo n.º 3
0
        ///
        public static GetContentEventArgs WorksExportExplorerFile(Explorer explorer, Panel panel, ExplorerModes mode, FarFile file, string fileName)
        {
            if (explorer == null) throw new ArgumentNullException("explorer");
            if (panel == null) throw new ArgumentNullException("panel");

            if (!explorer.CanGetContent)
                return null;

            // export file
            Log.Source.TraceInformation("ExportFile");
            var args = new GetContentEventArgs(mode, file, fileName);
            panel.UIGetContent(args);
            if (args.Result != JobResult.Done)
                return null;

            // no text or an actual file exists?
            if (args.UseText == null || !string.IsNullOrEmpty(args.UseFileName))
                return args;

            // export text
            string text = args.UseText as string;
            if (text == null)
            {
                IEnumerable collection = args.UseText as IEnumerable;
                if (collection == null)
                {
                    text = args.UseText.ToString();
                }
                else
                {
                    // write collection
                    using (StreamWriter writer = new StreamWriter(fileName, false, Encoding.Unicode))
                        foreach (var it in collection)
                            writer.WriteLine(it);
                    return args;
                }
            }

            // write text
            File.WriteAllText(fileName, text, Encoding.Unicode);
            args.CodePage = 1200;
            return args;
        }
Exemplo n.º 4
0
        /// <inheritdoc/>
        /// <remarks>
        /// The method updates the panel if its location is the same as that panel location.
        /// </remarks>
        public override void OnThatFileChanged(Panel that, EventArgs args)
        {
            var panel = that as ItemPanel;
            if (panel == null)
                return;

            if (panel.Explorer.Location != Explorer.Location)
                return;

            Update(true);
            Redraw();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Opens this panel as a child of the parent panel.
        /// </summary>
        /// <param name="parent">The opend parent panel. Null tells to use the active module panel, if any.</param>
        /// <remarks>
        /// When this panel is opened as a child of the parent panel, the parent is hidden, not closed.
        /// When the child closes itself later then the parent is shown again and its state is restored.
        /// </remarks>
        public void OpenChild(Panel parent)
        {
            // resolve 'null' parent
            if (parent == null)
            {
                // try to use the active as parent; do not use the passive, show as normal
                parent = Far.Api.Panel as Panel;
                if (parent == null)
                {
                    // go
                    Open();
                    return;
                }
            }

            // sanity check
            if (IsOpened || _Parent != null)
                throw new InvalidOperationException();

            // setup/fail
            if (!CanOpenAsChild(parent))
                return;

            // link
            _Parent = parent;
            _Parent._Child = this;

            // begin
            _Parent.SaveState();

            // go
            Open();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Closes this child panel and opens the parent panel if both panels are ready.
        /// </summary>
        /// <remarks>
        /// The method only tries to close the child panel.
        /// The panel is not closed if <see cref="CanClose"/> or <see cref="CanCloseChild"/> gets false.
        /// </remarks>
        public void CloseChild()
        {
            if (_Parent == null)
                throw new InvalidOperationException("The panel is not child.");

            // ask child
            if (!CanClose())
                return;

            // ask parent
            if (!_Parent.CanCloseChild())
                return;

            try
            {
                // clean
                UIClosed();
            }
            finally
            {
                // open parent
                _Parent._Panel.OpenReplace(this);

                // unlink
                _Parent._Child = null;
                _Parent = null;
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// It is called from <see cref="OpenChild"/> before linking the panels together.
 /// </summary>
 /// <param name="parent">The panel which is about to be parent.</param>
 /// <returns>False to cancel opening.</returns>
 /// <remarks>
 /// This method is designed for cases when the child opening depends on the parent.
 /// When this methods is called the parent is the active panel and its data can
 /// be used as usual. The panels are not yet linked together, use the parameter
 /// in order to access the parent.
 /// <para>
 /// If it returns false or throws then the parent panel remains opened.
 /// </para>
 /// </remarks>
 protected virtual bool CanOpenAsChild(Panel parent)
 {
     return true;
 }
Exemplo n.º 8
0
        internal void ApplyParameters(Panel panel)
        {
            // panel
            if (DataId != null) panel.Explorer.FileComparer = new FileMetaComparer(DataId);
            if (_IdleUpdate.HasValue && _IdleUpdate.Value) panel.IdleUpdate = true;
            if (Data != null)
                foreach (DictionaryEntry kv in Data)
                    panel.Data.Add(kv.Key, kv.Value);

            // info
            if (_SortMode.HasValue) panel.SortMode = _SortMode.Value;
            if (_TypeId.HasValue) panel.TypeId = _TypeId.Value;
            if (_ViewMode.HasValue) panel.ViewMode = _ViewMode.Value;
            if (Title != null) panel.Title = Title;
        }
Exemplo n.º 9
0
 /// <include file='doc.xml' path='doc/ScriptFork/*'/>
 /// <param name="panel">The panel.</param>
 public override sealed void EnterPanel(Panel panel)
 {
     if (AsEnterPanel == null)
         DoEnterPanel(panel);
     else
         A.InvokeScriptReturnAsIs(AsEnterPanel, this, panel);
 }
Exemplo n.º 10
0
 /// <summary>
 /// <see cref="Explorer.EnterPanel"/> worker.
 /// </summary>
 /// <param name="panel">The panel.</param>
 public virtual void DoEnterPanel(Panel panel)
 {
     base.EnterPanel(panel);
 }
Exemplo n.º 11
0
        public static void SwitchFullScreen(Panel panel)
        {
            if (panel == null) throw new ArgumentNullException("panel");

            // get/make the plan
            var iViewMode = panel.ViewMode;
            var plan = panel.GetPlan(iViewMode) ?? panel.ViewPlan;

            // drop widths of text columns
            foreach(var c in plan.Columns)
                if (c.Kind == "N" || c.Kind == "Z" || c.Kind == "O")
                    c.Width = 0;

            // switch
            plan.IsFullScreen = !plan.IsFullScreen;

            // set
            panel.SetPlan(iViewMode, plan);
            panel.Redraw();
        }
Exemplo n.º 12
0
 /// <summary>
 /// Opens the explorer in a panel that is a child of the specified panel.
 /// </summary>
 /// <param name="parent">The parent panel.</param>
 public void OpenPanelChild(Panel parent)
 {
     var panel = CreatePanel();
     panel.OpenChild(parent);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Updates the panel when this explorer gets assigned to it.
 /// </summary>
 /// <param name="panel">The panel.</param>
 public virtual void EnterPanel(Panel panel)
 {
 }
Exemplo n.º 14
0
 /// <summary>
 /// Called when files of another module panel have been changed.
 /// </summary>
 /// <param name="that">That panel.</param>
 /// <param name="args">.</param>
 /// <remarks>
 /// This panel may be updated if it contains data related to that panel.
 /// </remarks>
 public virtual void OnThatFileChanged(Panel that, EventArgs args)
 {
 }
Exemplo n.º 15
0
        /// <inheritdoc/>
        /// <remarks>
        /// Prepares for opening this panel as a child panel.
        /// </remarks>
        protected override bool CanOpenAsChild(Panel parent)
        {
            if (parent == null) throw new ArgumentNullException("parent");

            if (Lookup == null)
                return true;

            // lookup: try to post the current
            // 090809 ??? perhaps I have to rethink
            TablePanel tp = this as TablePanel;
            if (tp != null)
            {
                // assume parent Description = child Name
                string value = parent.CurrentFile.Description;
                PostName(value);
            }

            return true;
        }
Exemplo n.º 16
0
 /// <summary>
 /// INTERNAL
 /// </summary>
 public abstract Works.IPanelWorks WorksPanel(Panel panel, Explorer explorer);