예제 #1
0
        public Console(IInput input, IViewer viewer)
        {
            Command = new Command();
            _Filter = LogFilter.All;

            _Initial(input , viewer);
        }
예제 #2
0
        /// <summary>
        /// Checks if any viewers have changed since last Update, and if so it updates the grid.
        /// </summary>
        /// <returns>Whether anything has changed.</returns>
        public bool Activity()
        {
            bool hasAnythingChanged = false;

            int xIndex;
            int yIndex;

            foreach (KeyValuePair <IViewer, ViewerInformation> kvp in this.mViewers)
            {
                IViewer           viewer      = kvp.Key;
                ViewerInformation information = kvp.Value;

                WorldToIndex(viewer.X, viewer.Y, out xIndex, out yIndex);

                int radiusAsInt = MathFunctions.RoundToInt(viewer.WorldViewRadius / mGridSpacing);
                if (xIndex != information.LastX || yIndex != information.LastY)
                {
                    hasAnythingChanged = true;
                    information.LastX  = xIndex;
                    information.LastY  = yIndex;

                    if (xIndex >= radiusAsInt && yIndex >= radiusAsInt &&
                        xIndex + radiusAsInt < mNumberOfXTiles && yIndex + radiusAsInt < mNumberOfYTiles)
                    {
                        UpdateViewersLocalVisibilityGrid(viewer, information);
                    }
                }
            }
            if (hasAnythingChanged)
            {
                UpdateRevealedFromViewers();
            }
            return(hasAnythingChanged);
        }
예제 #3
0
        /// <summary>
        /// Adds an IViewer to this grid.
        /// </summary>
        /// <param name="viewerToAdd">The viewer to add.</param>
        public void AddViewer(IViewer viewerToAdd)
        {
            int localGridDimension = MathFunctions.RoundToInt(viewerToAdd.WorldViewRadius / mGridSpacing) * 2 + 1;

            VisibilityGrid localVisibilityGrid = new VisibilityGrid(0, 0, mGridSpacing,
                                                                    localGridDimension, localGridDimension);

            ViewerInformation viewerInformation = new ViewerInformation();

            viewerInformation.LocalVisibilityGrid = localVisibilityGrid;

            if (mFogFactor > 0)
            {
                localVisibilityGrid.FogColor      = FogColor;
                localVisibilityGrid.FogShade      = FogShade;
                localVisibilityGrid.FogResolution = FogResolution;
            }
            int xIndex;
            int yIndex;

            mViewers.Add(viewerToAdd, viewerInformation);

            WorldToIndex(viewerToAdd.X, viewerToAdd.Y, out xIndex, out yIndex);

            int radiusAsInt = MathFunctions.RoundToInt(viewerToAdd.WorldViewRadius / mGridSpacing);

            if (xIndex >= radiusAsInt && yIndex >= radiusAsInt &&
                xIndex + radiusAsInt < mNumberOfXTiles && yIndex + radiusAsInt < mNumberOfYTiles)
            {
                UpdateViewersLocalVisibilityGrid(viewerToAdd, viewerInformation);
            }

            UpdateRevealedFromViewers();
        }
예제 #4
0
        private void UpdateRevealedFromViewers()
        {
            MakeAllHidden();

            int x;
            int y;

            int xIndex;
            int yIndex;
            int radiusAsInt;

            foreach (KeyValuePair <IViewer, ViewerInformation> kvp in mViewers)
            {
                IViewer viewer = kvp.Key;
                WorldToIndex(viewer.X, viewer.Y, out xIndex, out yIndex);
                radiusAsInt = MathFunctions.RoundToInt(viewer.WorldViewRadius / mGridSpacing);

                if (xIndex >= radiusAsInt && yIndex >= radiusAsInt &&
                    xIndex + radiusAsInt < mNumberOfXTiles && yIndex + radiusAsInt < mNumberOfYTiles)
                {
                    ViewerInformation info        = kvp.Value;
                    VisibilityGrid    gridToPlace = info.LocalVisibilityGrid;

                    int   xOffset = MathFunctions.RoundToInt((gridToPlace.mXSeed - mXSeed) / mGridSpacing);
                    int   yOffset = MathFunctions.RoundToInt((gridToPlace.mYSeed - mYSeed) / mGridSpacing);
                    int   fogX, fogY;
                    Color sourceColor;
                    Color destinationColor;
                    for (x = 0; x < gridToPlace.mNumberOfXTiles; x++)
                    {
                        for (y = 0; y < gridToPlace.mNumberOfYTiles; y++)
                        {
                            mRevealedTiles[x + xOffset][y + yOffset] |= gridToPlace.mRevealedTiles[x][y];

                            if (mFogFactor > 0)
                            {
                                for (fogX = 0; fogX < mFogFactor; fogX++)
                                {
                                    for (fogY = 0; fogY < mFogFactor; fogY++)
                                    {
                                        sourceColor      = gridToPlace.mFogImageData.GetPixelColor(x * mFogFactor + fogX, y * mFogFactor + fogY);
                                        destinationColor = mFogImageData.GetPixelColor((x + xOffset) * mFogFactor + fogX, (y + yOffset) * mFogFactor + fogY);
                                        if (sourceColor.R > destinationColor.R)
                                        {
                                            destinationColor = sourceColor;
                                        }
                                        mFogImageData.SetPixel((x + xOffset) * mFogFactor + fogX, (y + yOffset) * mFogFactor + fogY, destinationColor);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (mFogFactor > 0 && mFogTexture != null)
            {
                mFogImageData.ToTexture2D(mFogTexture);
            }
        }
예제 #5
0
 public Console(IInput input, IViewer viewer)
 {
     Command   = new Command();
     _Filter   = LogFilter.All;
     _Commands = new Dictionary <string, string>();
     _Initial(input, viewer);
 }
예제 #6
0
        private void BeginShowNewWindow(IViewer matchedPlugin, string path)
        {
            _viewWindow         = new MainWindow();
            _viewWindow.Closed += (sender2, e2) =>
            {
                _viewWindow.Dispose();
                _viewWindow = null;
                GC.Collect();
            };

            try
            {
                _viewWindow.BeginShow(matchedPlugin, path);
            }
            catch (Exception e) // if current plugin failed, switch to default one
            {
                Debug.WriteLine(e.ToString());
                Debug.WriteLine(e.StackTrace);

                if (matchedPlugin.GetType() != PluginManager.GetInstance().DefaultPlugin)
                {
                    matchedPlugin.Dispose();
                    _viewWindow.BeginShow(PluginManager.GetInstance().DefaultPlugin.CreateInstance <IViewer>(), path);
                }
            }
        }
예제 #7
0
        /// <summary>
        /// Creates standard Far viewer ready for opening (F3)
        /// </summary>
        /// <param name="filePath">Existing file to view.</param>
        public static IViewer CreateViewer(string filePath)
        {
            IViewer view = Far.Api.CreateViewer();

            view.FileName = filePath;
            return(view);
        }
예제 #8
0
        static void EdgeSeparationTrackBarValueChanged(object sender, EventArgs e)
        {
            var     edgeSeparationTruckBar = (TrackBar)sender;
            GViewer gviewer = GetGviewer(edgeSeparationTruckBar);

            Graph drawingGraph = gviewer.Graph;

            if (drawingGraph == null)
            {
                return;
            }


            EdgeRoutingSettings edgeRoutingSettings = drawingGraph.LayoutAlgorithmSettings.EdgeRoutingSettings;

            edgeRoutingSettings.EdgeRoutingMode = EdgeRoutingMode.SplineBundling;
            if (edgeRoutingSettings.BundlingSettings == null)
            {
                edgeRoutingSettings.BundlingSettings = new BundlingSettings();
            }
            edgeRoutingSettings.BundlingSettings.EdgeSeparation = GetEdgeSeparation(edgeSeparationTruckBar);
            var br = new SplineRouter(drawingGraph.GeometryGraph, 1, 1, Math.PI / 6, edgeRoutingSettings.BundlingSettings);

            br.Run();

            IViewer iv = gviewer;

            foreach (IViewerObject edge in iv.Entities)
            {
                if (edge is IViewerEdge)
                {
                    iv.Invalidate(edge);
                }
            }
        }
예제 #9
0
        unsafe void DockViewer_Load(object sender, EventArgs e)
        {
            try
            {
                viewer = new Viewer();
                viewer.LoadEffectFunc += () =>
                {
                    StopViewer();

                    viewer.RemoveEffect();

                    Export();

                    IsChanged = false;

                    return(true);
                };

                IsPlaying = false;
                IsPaused  = false;
                IsChanged = true;
                current   = 0;

                Core.Viewer = viewer;
            }
            catch (Exception exception)
            {
                MessageBox.Show("描画画面の生成に失敗しました。DirectXのバージョンの問題、メモリの不足等が考えられます。");
                throw exception;
            }
        }
예제 #10
0
 public Console(IInput input, IViewer viewer)
 {
     Command = new Command();
     _Filter = LogFilter.All;
     _Commands = new Dictionary<string, string>();
     _Initial(input, viewer);
 }
예제 #11
0
        private byte CalculateFogColorByDistance(float x, float y, byte alpha, IViewer viewer)
        {
            int shadeValue = 127;// alpha;

            int radiusAsInt;
            int radiusAsIntSquared;
            //We need to extend the radius slightly to allow smooth gradients on grid squares just out side the viewable area.
            int   radiusExtended;
            int   radiusExtendedSquared;
            float xIndex;
            float yIndex;
            float distance;
            float calculatedValue;

            {
                radiusAsInt           = MathFunctions.RoundToInt(viewer.WorldViewRadius / mGridSpacing);
                radiusExtended        = radiusAsInt + 2;
                radiusAsIntSquared    = radiusAsInt * radiusAsInt;
                radiusExtendedSquared = radiusExtended * radiusExtended;
                WorldToIndex(viewer.X, viewer.Y, out xIndex, out yIndex);
                distance = ((x - xIndex) * (x - xIndex)) + ((y - yIndex) * (y - yIndex));
                if (distance <= radiusAsIntSquared)
                {
                    calculatedValue = distance / radiusAsIntSquared;

                    calculatedValue = MathHelper.Max(0, MathHelper.Min((calculatedValue /** calculatedValue*/), 1.0f));
                    shadeValue      = (byte)((1.0f - calculatedValue) * 127);
                    alpha           = (byte)MathHelper.Min(MathHelper.Max(alpha, shadeValue), 127);
                }
            }

            return(alpha);
        }
예제 #12
0
        public SceneManager(ILog log, ISceneManagerSettings settings, IViewer viewer)
        {
            this.log      = log;
            this.settings = settings;
            this.viewer   = viewer;

            Init();
        }
예제 #13
0
        public XtraTabControl InitiaizeRelatedViewer(IViewer editorViewer, int pageIndex)
        {
            _tabControl = _CommonTabControl.InitializeCommonTabControl((Control)editorViewer, editorViewer.HeaderTitle,
                                                                       pageIndex, true, true,
                                                                       (ViewerName)editorViewer.ViewerID);

            return(_tabControl);
        }
예제 #14
0
        /// <summary>
        /// Removes a viewer.
        /// </summary>
        /// <param name="viewerToRemove">The argument IViewer to remove.</param>
        public void RemoveViewer(IViewer viewerToRemove)
        {
            mViewers.Remove(viewerToRemove);

            // This have definitely changed, so we gotta refresh everything.
            // Fortunately there's no re-calculation here, just paste everything
            // down.  The newly-removed guy will not be placed.
            UpdateRevealedFromViewers();
        }
예제 #15
0
        public void OpenVideoViewer(ViewerType viewerType, bool showWaitingInfo)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new CbGeneric <ViewerType, bool>(this.OpenVideoViewer), viewerType, showWaitingInfo);
            }
            else
            {
                this.haveCloseVedio = false;
                TabPage page;
                if (this.tabControl1.TabPages.Count == 0)
                {
                    page = new TabPage("视频");
                    this.tabControl1.TabPages.Add(page);
                }
                else
                {
                    page = this.tabControl1.TabPages[0];
                    (page.Controls[0] as IViewer).Close();
                    page.Controls.Clear();
                    this.Width = this.Width - this.panel_plus.Width;
                }
                switch (viewerType)
                {
                case ViewerType.VideoRequest:
                {
                    VideoRequestViewer videoRequestViewer = new VideoRequestViewer();
                    videoRequestViewer.Dock          = System.Windows.Forms.DockStyle.Fill;
                    videoRequestViewer.ReceiveVideo += new CbGeneric(videoRequestViewer_ReceiveVideo);
                    videoRequestViewer.RejectVideo  += new CbGeneric(videoRequestViewer_RejectVideo);
                    page.Controls.Add(videoRequestViewer);
                    this.currentViewer      = videoRequestViewer;
                    this.panel_plus.Visible = true;
                    int screenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
                    this.Width            = this.Width + 224 > screenWidth ? screenWidth : this.Width + 224;
                    this.panel_plus.Width = 224;
                    break;
                }

                case ViewerType.VideoView:
                {
                    videoViewer                    = new VideoViewer(userName, friendName, showWaitingInfo, this.multimediaManager);
                    videoViewer.CloseVideo        += new CbGeneric(videoViewer_CloseVideo);
                    videoViewer.OfflineCloseVideo += new CbGeneric(videoViewer_OfflineCloseVideo);

                    page.Controls.Add(videoViewer);
                    this.panel_plus.Visible = true;
                    int screenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
                    this.Width            = this.Width + 346 > screenWidth ? screenWidth : this.Width + 346;
                    this.panel_plus.Width = 346;
                    this.currentViewer    = videoViewer;
                    break;
                }
                }
                this.haveVideo = true;
            }
        }
예제 #16
0
파일: App.cs 프로젝트: ktei/UnitTestExample
 public App(
     IGitHubClient gitHubClient,
     IViewer viewer,
     IMapper mapper
     )
 {
     _gitHubClient = gitHubClient;
     _viewer       = viewer;
     _mapper       = mapper;
 }
예제 #17
0
        void MoveVertical(Point pos, int ydir)
        {
            CharacterHandler handler = Handler as CharacterHandler;
            IViewer          viewer  = handler.Viewer;

            if (viewer != null)
            {
                Canvas  canvas = handler.CurrentPage.Canvas;
                BitFont font   = handler.CurrentPage.Font;

                Point newCursor      = pos;
                float fontHeight     = ((float)font.Height) * handler.ZoomRatio.Height;
                int   verticalOffset = (int)((viewer.ViewSize.Height + fontHeight - 1) / fontHeight);
                newCursor.Y += verticalOffset * ydir;
                if (newCursor.Y > canvas.Height - 1)
                {
                    newCursor.Y = canvas.Height - 1;
                }
                if (newCursor.Y < 0)
                {
                    newCursor.Y = 0;
                }
                //Rectangle rect = handler.SelectedRegion;

                handler.CursorPosition = newCursor;

                /*handler.SetCursorPosition(newCursor, false);
                 * handler.InvalidateCharacterRegion(new Rectangle(pos, new Size(1,1)));
                 * rect.Normalize();
                 * rect.Width++;
                 * rect.Height++;
                 *
                 * handler.InvalidateCharacterRegion(rect);
                 */

                Point scrollPos = viewer.ScrollPosition;
                scrollPos.Y += (int)Math.Round(verticalOffset * fontHeight) * ydir;
                if (scrollPos.Y < 0)
                {
                    scrollPos.Y = 0;
                }
                viewer.ScrollPosition = scrollPos;

                /*
                 * handler.InvalidateCharacterRegion(new Rectangle(newCursor, new Size(1,1)));
                 * rect = handler.SelectedRegion;
                 * rect.Normalize();
                 * rect.Width++;
                 * rect.Height++;
                 *
                 * handler.InvalidateCharacterRegion(rect);
                 */
            }
        }
예제 #18
0
        private void _Initial(IInput input, IViewer viewer)
        {
            _Viewer             = viewer;
            _Input              = input;
            _Input.OutputEvent += _Run;

            Command.RegisterEvent   += _OnRegister;
            Command.UnregisterEvent += _OnUnregister;

            Command.Register("help", _Help);
        }
예제 #19
0
    public static void Hide(IViewer viewer)
    {
        List <HexCell> cells = GetVisibleCells(viewer);

        for (int i = 0; i < cells.Count; i++)
        {
            cells[i].DecreaseVisibility();
        }

        m_listPool.Restore(cells);
    }
예제 #20
0
 /// Launches net poisoning process until all computers are not poisoned.
 public static ulong MainProcess(IReader reader, IViewer viewer)
 {
     var input = reader.ReadFromFile();
     var net = new Net(input.adjacencyMatrix, input.computers);
     ulong iteration = 0;
     while (!Logic.Iteration(net))
     {
         viewer.View(net, iteration++);
     }
     viewer.View(net, iteration++);
     return iteration;
 }
예제 #21
0
        internal void BeginShow(IViewer matchedPlugin, string path,
                                Action <string, ExceptionDispatchInfo> exceptionHandler)
        {
            _path  = path;
            Plugin = matchedPlugin;

            ContextObject.ViewerWindow = this;

            // get window size before showing it
            try
            {
                Plugin.Prepare(path, ContextObject);
            }
            catch (Exception e)
            {
                exceptionHandler(path, ExceptionDispatchInfo.Capture(e));
            }

            SetOpenWithButtonAndPath();

            // revert UI changes
            ContextObject.IsBusy = true;

            var margin = windowFrameContainer.Margin.Top * 2;

            var newHeight = ContextObject.PreferredSize.Height + margin +
                            (ContextObject.TitlebarOverlap ? 0 : windowCaptionContainer.Height);
            var newWidth = ContextObject.PreferredSize.Width + margin;

            ResizeAndCenter(this, new Size(newWidth, newHeight), _canOldPluginResize, ContextObject.CanResize);

            if (Visibility != Visibility.Visible)
            {
                Show();
            }

            ShowWindowCaptionContainer(null, null);
            //WindowHelper.SetActivate(new WindowInteropHelper(this), ContextObject.CanFocus);

            // load plugin, do not block UI
            Dispatcher.BeginInvoke(new Action(() =>
            {
                try
                {
                    Plugin.View(path, ContextObject);
                }
                catch (Exception e)
                {
                    exceptionHandler(path, ExceptionDispatchInfo.Capture(e));
                }
            }),
                                   DispatcherPriority.Input);
        }
예제 #22
0
 public ItemController(IViewer view) : base(view)
 {
     ParseFunc    = new Func <List <string[]>, List <Item> >((c) => (new EntityParser(UserId).ParseToItems(c)));
     InsertAction = new Func <List <Item>, int>((e) =>
     {
         using (var context = new InventoryDbEntities())
         {
             context.Items.AddRange(e);
             return(context.SaveChanges());
         }
     });
 }
예제 #23
0
        private void GenerujTaby(TabsWidget widgetBase, NsPanel panelRodzic, IViewer viewer, bool isPostBack)
        {
            var tabs = NsTabs.UtworzTabs(widgetBase);

            panelRodzic.Controls.Add(tabs.Panel);
            foreach (var widgetBaseTab in widgetBase.Tabs)
            {
                var tab = NsPanel.UtworzPanel(widgetBaseTab);
                GenerujElementy(widgetBaseTab, tab, viewer, isPostBack);
                tabs.AddTab(tab);
            }
        }
예제 #24
0
        public void UnsafeView(IntPtr dataPtr, Type type)
        {
#if UNITY_EDITOR
            TypeName = type.ToReadableName();
            var viewerFactory = _register.FindFactory(type);
            if (Viewer == null || Viewer.GetType() != viewerFactory.Type)
            {
                Viewer = (IViewer)viewerFactory.Create();
            }
            Viewer.View(dataPtr, type, _register);
#endif
        }
예제 #25
0
        internal void BeginShow(IViewer matchedPlugin, string path)
        {
            ContextObject.CurrentContentContainer = viewContentContainer;
            ContextObject.ViewerPlugin            = matchedPlugin;

            // get window size before showing it
            matchedPlugin.BoundViewSize(path, ContextObject);

            Show();

            matchedPlugin.View(path, ContextObject);
        }
예제 #26
0
        /// Launches net poisoning process until all computers are not poisoned.
        public static ulong MainProcess(IReader reader, IViewer viewer)
        {
            var   input     = reader.ReadFromFile();
            var   net       = new Net(input.adjacencyMatrix, input.computers);
            ulong iteration = 0;

            while (!Logic.Iteration(net))
            {
                viewer.View(net, iteration++);
            }
            viewer.View(net, iteration++);
            return(iteration);
        }
예제 #27
0
 public PermissionController(IViewer view) : base(view)
 {
     ParseFunc = new Func <List <string[]>, List <TransactionPermission> >((c) =>
                                                                           (new EntityParser(UserId).ParseToPermission(c)));
     InsertAction = new Func <List <TransactionPermission>, int>((e) =>
     {
         using (var context = new InventoryDbEntities())
         {
             context.TransactionPermissions.AddRange(e);
             return(context.SaveChanges());
         }
     });
 }
예제 #28
0
        protected override void ProcessRecord()
        {
            IViewer viewer = CreateViewer();

            if (Modal)
            {
                viewer.Open(OpenMode.Modal);
            }
            else
            {
                viewer.Open();
            }
        }
예제 #29
0
        public void Initialize(PluginConfiguration configuration, Action <Action <ISystemController, IRaceController> > queueCommand)
        {
            try
            {
                _viewer = new WebViewer(_logger, queueCommand, this, _kernel);

                configuration.DashboardViewers.Add(_viewer);
            }
            catch (Exception ex)
            {
                _viewer = null;
                _logger.Error("Failed to initialize onboard web ui", ex);
            }
        }
예제 #30
0
        protected void GenerujElementy(WidgetBase widgetBase, NsPanel panelRodzic, IViewer viewer, bool isPostBack)
        {
            if (widgetBase is Action)
            {
                var akcja = widgetBase as Action;
                var a     = UtworzAkcja(akcja, viewer);
                panelRodzic.Controls.Add(a);
            }
            else
            if (widgetBase is Panel)
            {
                var oPanel = widgetBase as Panel;
                var panel  = NsPanel.UtworzPanel(oPanel);

                panelRodzic.Controls.Add(panel);
                foreach (var element in oPanel.Elementy)
                {
                    GenerujElementy(element, panel, viewer, isPostBack);
                }
            }
            else if (widgetBase is TabsWidget)
            {
                GenerujTaby((TabsWidget)widgetBase, panelRodzic, viewer, isPostBack);
            }
            else
            {
                //mamy kontrolkę - generują ją
                if (widgetBase.Label != null)
                {
                    var label = UtworzLabel(widgetBase.Name);
                    label.Style["display"] = "block";
                    label.Width            = new Unit("99%");
                    label.ToolTip          = widgetBase.ToolTip;
                    panelRodzic.Controls.Add(label);
                }

                var kontrolka = GenerujKontrolke(widgetBase, panelRodzic, viewer, isPostBack);

                var kont = kontrolka as WebControl;
                if (kont != null)
                {
                    kont.Style["display"] = "block";
                    kont.Width            = new Unit("99%");
                    kont.Style[HtmlTextWriterStyle.MarginBottom] = "10px";
                }

                panelRodzic.Controls.Add(kontrolka);
            }
        }
예제 #31
0
        internal IViewer CreateViewer()
        {
            IViewer viewer = Far.Api.CreateViewer();

            viewer.DeleteSource   = DeleteSource;
            viewer.DisableHistory = DisableHistory;
            viewer.FileName       = GetUnresolvedProviderPathFromPSPath(Path);
            viewer.Switching      = Switching;
            viewer.Title          = Title;
            if (CodePage >= 0)
            {
                viewer.CodePage = CodePage;
            }
            return(viewer);
        }
예제 #32
0
 public ConsoleController(string instruction, IContinueChecker checkerProcess,
                          INumbericsValidator numbericsCheker, IFigureValidator figuresChecker,
                          TriangleFactory figureBuilder, IComparer <IFigure> figuresComparer,
                          FiguresSorterByDescendingFactory sorterFactory, IViewer figuresViwer)
 {
     _insrtuction      = instruction;
     _checker          = checkerProcess;
     _numbericsCheker  = numbericsCheker;
     _figuresChecker   = figuresChecker;
     _figureBuilder    = figureBuilder;
     _figuresComparer  = figuresComparer;
     _sorterFactory    = sorterFactory;
     _figuresViwer     = figuresViwer;
     _figuresContainer = new Queue <IFigure>();
 }
        public void InitializeCollector(IViewer viewer, ViewerName viewerName)
        {
            if (ActiveCollector == null)
            {
                ActiveCollector = (AbstractDataCollector <TEntity>)DataCollectorFactory.GetDataCollectorFactory <TEntity>(viewerName);
            }

            if (ActiveCollector != null)
            {
                ActiveCollector.ActiveViewer = viewer;
            }

            ActiveViewerName = viewerName;

            Collect(ActiveCollector);
        }
예제 #34
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="viewerPar">the viewer that the editor communicates with</param>
        public LayoutEditor(IViewer viewerPar) {
            viewer = viewerPar;
            HookUpToViewerEvents();
            ToggleEntityPredicate =
                (modifierKeys, mouseButtons, draggingParameter) => LeftButtonIsPressed(mouseButtons);
            NodeInsertPredicate =
                (modifierKeys, mouseButtons, draggingParameter) =>
                MiddleButtonIsPressed(mouseButtons) && draggingParameter == false;
            DecorateObjectForDragging = TheDefaultObjectDecorator;
            RemoveObjDraggingDecorations = TheDefaultObjectDecoratorRemover;
            DecorateEdgeForDragging = TheDefaultEdgeDecoratorStub;
            DecorateEdgeLabelForDragging = TheDefaultEdgeLabelDecoratorStub;
            RemoveEdgeDraggingDecorations = TheDefaultEdgeDecoratorStub;

            geomGraphEditor.ChangeInUndoRedoList += LayoutEditorChangeInUndoRedoList;

        }
예제 #35
0
        /// <summary>
        /// Adds an IViewer to this grid.
        /// </summary>
        /// <param name="viewerToAdd">The viewer to add.</param>
        public void AddViewer(IViewer viewerToAdd)
        {
            int localGridDimension = MathFunctions.RoundToInt(viewerToAdd.WorldViewRadius / mGridSpacing) * 2 + 1;

            VisibilityGrid localVisibilityGrid = new VisibilityGrid(0, 0, mGridSpacing,
                localGridDimension, localGridDimension);

            ViewerInformation viewerInformation = new ViewerInformation();
            viewerInformation.LocalVisibilityGrid = localVisibilityGrid;

            if (mFogFactor > 0)
            {
                localVisibilityGrid.FogColor = FogColor;
                localVisibilityGrid.FogShade = FogShade;
                localVisibilityGrid.FogResolution = FogResolution;
            }
            int xIndex;
            int yIndex;
            mViewers.Add(viewerToAdd, viewerInformation);

            WorldToIndex(viewerToAdd.X, viewerToAdd.Y, out xIndex, out yIndex);

            int radiusAsInt = MathFunctions.RoundToInt(viewerToAdd.WorldViewRadius / mGridSpacing);

            if (xIndex >= radiusAsInt && yIndex >= radiusAsInt &&
                xIndex + radiusAsInt < mNumberOfXTiles && yIndex + radiusAsInt < mNumberOfYTiles)
            {

                UpdateViewersLocalVisibilityGrid(viewerToAdd, viewerInformation);
            }

            UpdateRevealedFromViewers();
        }
예제 #36
0
        /// <summary>
        /// Returns whether a given world position is in view of a given viewer.
        /// </summary>
        /// <param name="viewer">The viewer to check visibility for.</param>
        /// <param name="targetPosition">The world coordinates.</param>
        /// <returns>Whether in view.</returns>
        public bool IsPositionInDirectView(IViewer viewer, ref Vector3 targetPosition)
        {
            if (mViewers.ContainsKey(viewer)) 
            {
                VisibilityGrid grid = mViewers[viewer].LocalVisibilityGrid;

                return grid.IsRevealedWorld(targetPosition.X, targetPosition.Y);
            }
#if DEBUG
            else 
            {
                throw new InvalidOperationException("Viewer does not exist in Visbility grid");
            }
#else
            return false;
#endif
        }
예제 #37
0
        private void UpdateViewersLocalVisibilityGrid(IViewer viewer, ViewerInformation viewerInformation)
        {
            VisibilityGrid localGrid = viewerInformation.LocalVisibilityGrid;

            localGrid.MakeAllHidden();
            localGrid.ClearBlockedTiles();

            int viewRadius = MathFunctions.RoundToInt(viewer.WorldViewRadius / mGridSpacing);

            int xIndex;
            int yIndex;

            WorldToIndex(viewer.X, viewer.Y, out xIndex, out yIndex);

            float tileCenteredXPosition;
            float tileCenteredYPosition;

            IndexToWorld(xIndex, yIndex, out tileCenteredXPosition, out tileCenteredYPosition);

            viewerInformation.LastX = xIndex;
            viewerInformation.LastY = yIndex;

            localGrid.mXSeed =
                tileCenteredXPosition - viewer.WorldViewRadius;


            localGrid.mYSeed =
                tileCenteredYPosition - viewer.WorldViewRadius;

            int xOffset = MathFunctions.RoundToInt((localGrid.mXSeed - mXSeed) / mGridSpacing);
            int yOffset = MathFunctions.RoundToInt((localGrid.mYSeed - mYSeed) / mGridSpacing);

            // copy over the blocked areas to the viewer
            int y;
            int fogX, fogY;
            byte shadedValue;
            Color shadedColor;
            float invertedFogFactor = 1.0f;
            if (mFogFactor > 1)
                invertedFogFactor = 1.0f / mFogFactor;
            for (int x = 0; x < localGrid.mNumberOfXTiles; x++)
            {
                for (y = 0; y < localGrid.mNumberOfYTiles; y++)
                {
                    localGrid.mBlockedTiles[x][y] = mBlockedTiles[x + xOffset][y + yOffset];
                }
            }

            localGrid.MakeAllHidden();
            localGrid.RevealCircle(viewRadius, viewRadius, viewRadius);
            localGrid.BleedDirectlyVisibleToWalls();

            if (mFogFactor > 0)
            {
                for (int x = 0; x < localGrid.mNumberOfXTiles; x++)
                {
                    for (y = 0; y < localGrid.mNumberOfYTiles; y++)
                    {
                        for (fogX = 0; fogX < mFogFactor; fogX++)
                        {
                            for (fogY = 0; fogY < mFogFactor; fogY++)
                            {
                                shadedColor = localGrid.mFogImageData.GetPixelColor(x * mFogFactor + fogX, y * mFogFactor + fogY);
                                shadedValue = 0;
                                if (localGrid.mRevealedTiles[x][y] != 0)
                                    shadedValue = localGrid.CalculateFogColorByDistance(x + (fogX * invertedFogFactor), y + (fogY * invertedFogFactor), shadedColor.R, viewer);
                                else if (shadedColor.R > FogShade)
                                    shadedValue = FogShade;
#if XNA4
                                //shadedColor = Color.FromNonPremultiplied(FogColor.R, FogColor.G, FogColor.B, shadedValue);
                                shadedColor = Color.FromNonPremultiplied(shadedValue, shadedValue, shadedValue, 255);
#else
								shadedColor = FogColor;
								shadedColor.A = shadedValue;
#endif
                                localGrid.mFogImageData.SetPixel(x * mFogFactor + fogX, y * mFogFactor + fogY, shadedColor);
                            }
                        }
                    }
                }
            }
        }
예제 #38
0
        private byte CalculateFogColorByDistance(float x, float y, byte alpha, IViewer viewer)
        {
            int shadeValue = 127;// alpha;

            int radiusAsInt;
            int radiusAsIntSquared;
            //We need to extend the radius slightly to allow smooth gradients on grid squares just out side the viewable area.
            int radiusExtended;
            int radiusExtendedSquared;
            float xIndex;
            float yIndex;
            float distance;
            float calculatedValue;

            {
                radiusAsInt = MathFunctions.RoundToInt(viewer.WorldViewRadius / mGridSpacing);
                radiusExtended = radiusAsInt + 2;
                radiusAsIntSquared = radiusAsInt * radiusAsInt;
                radiusExtendedSquared = radiusExtended * radiusExtended;
                WorldToIndex(viewer.X, viewer.Y, out xIndex, out yIndex);
                distance = ((x - xIndex) * (x - xIndex)) + ((y - yIndex) * (y - yIndex));
                if (distance <= radiusAsIntSquared)
                {
                    calculatedValue = distance / radiusAsIntSquared;
 
                    calculatedValue = MathHelper.Max(0, MathHelper.Min( (calculatedValue /** calculatedValue*/), 1.0f));
                    shadeValue = (byte)((1.0f-calculatedValue) * 127);
                    alpha = (byte)MathHelper.Min(MathHelper.Max(alpha, shadeValue), 127);
                }
            }

            return alpha;
        }
예제 #39
0
        private void _Initial(IInput input, IViewer viewer)
        {
            _Viewer = viewer;
            _Input = input;
            _Input.OutputEvent += _Run;

            Command.RegisterEvent += _OnRegister;
            Command.UnregisterEvent += _OnUnregister;

            Command.Register("help", _Help);
        }
 internal RemoveNodeUndoAction(IViewer viewer, IViewerNode node) :base(viewer.ViewerGraph.DrawingGraph.GeometryGraph){
     this.viewer = viewer;
     this.removedNode = node;
     this.GraphBoundingBoxAfter = viewer.ViewerGraph.DrawingGraph.BoundingBox; //do not change the bounding box
 }
예제 #41
0
        unsafe void DockViewer_Load(object sender, EventArgs e)
        {
            try
            {
                viewer = new Viewer();
                viewer.LoadEffectFunc += () =>
                    {
                        StopViewer();

                        viewer.RemoveEffect();

                        Export();

                        IsChanged = false;

                        return true;
                    };

                IsPlaying = false;
                IsPaused = false;
                IsChanged = true;
                current = 0;

                Core.Viewer = viewer;
            }
            catch(Exception exception)
            {
                MessageBox.Show("描画画面の生成に失敗しました。DirectXのバージョンの問題、メモリの不足等が考えられます。");
                throw exception;
            }
        }
예제 #42
0
        ///<summary>
        ///</summary>
        public static void RouteEdgesRectilinearly(IViewer viewer) {
            var geomGraph = viewer.Graph.GeometryGraph;
            var settings = viewer.Graph.LayoutAlgorithmSettings;
            RectilinearInteractiveEditor.CreatePortsAndRouteEdges(settings.NodeSeparation / 3, 1, geomGraph.Nodes, geomGraph.Edges,
                                         settings.EdgeRoutingSettings.EdgeRoutingMode, true,
                                         settings.EdgeRoutingSettings.UseObstacleRectangles, settings.EdgeRoutingSettings.BendPenalty);
            var labelPlacer = new EdgeLabelPlacement(geomGraph);
            labelPlacer.Run();

        }
예제 #43
0
        /// <summary>
        /// Removes a viewer.
        /// </summary>
        /// <param name="viewerToRemove">The argument IViewer to remove.</param>
        public void RemoveViewer(IViewer viewerToRemove)
        {
            mViewers.Remove(viewerToRemove);

            // This have definitely changed, so we gotta refresh everything.
            // Fortunately there's no re-calculation here, just paste everything
            // down.  The newly-removed guy will not be placed.
            UpdateRevealedFromViewers();
        }
 internal RemoveEdgeUndoAction(Graph graph, IViewer viewer, IViewerEdge edge) :base(graph.GeometryGraph){
     this.viewer = viewer;
     this.removedEdge = edge;
     this.GraphBoundingBoxAfter = graph.BoundingBox; //do not change the bounding box
 }
 internal AddEdgeUndoAction(IViewer viewer, IViewerEdge edge) :base(viewer.ViewerGraph.DrawingGraph.GeometryGraph){
     this.viewer = viewer;
     this.addedEdge = edge;
 }
 internal AddNodeUndoAction(Graph graph, IViewer viewer, IViewerNode node) :base(graph.GeometryGraph){
     this.viewer = viewer;
     this.addedNode = node;
 }
예제 #47
0
파일: GroupViewer.cs 프로젝트: hkiaipc/C3
 public void AddViewer(IViewer viewer)
 {
     this._uc.AddControl(viewer.UC);
 }